Re: Flash Player Launching Process With CreateProcess
Jay wrote:
For some reason, the EnumWindows Function:
BOOL CALLBACK EnumOpenWindows(HWND hwnd, LPARAM lParam)
{
DWORD dwID;
DWORD currProcId;
FILE* fp;
struct _HwndProcStruct* locHPStruct;
fp = fopen(THREAD_LOG_FILE,APPEND_MODE);
fprintf(fp,"*******************<EnumOpenWindows>************
*******\n");
fclose(fp);
locHPStruct = (struct _HwndProcStruct*)lParam;
currProcId = locHPStruct->procID;
dwID = 0;
GetWindowThreadProcessId(hwnd, &dwID);
fp = fopen(THREAD_LOG_FILE,APPEND_MODE);
fprintf(fp,"currProcId=%d dwID2=%d\n",currProcId,dwID);
fclose(fp);
if(dwID == currProcId)
{
locHPStruct->WindHandle = hwnd;
fp = fopen(THREAD_LOG_FILE,APPEND_MODE);
fprintf(fp,"FALSE\n");
fprintf(fp,"*******************</EnumOpenWindows>***********
********\n");
fclose(fp);
return FALSE;
}
else
{
fp = fopen(THREAD_LOG_FILE,APPEND_MODE);
fprintf(fp,"TRUE\n");
fprintf(fp,"*******************</EnumOpenWindows>***********
********\n");
fclose(fp);
return TRUE;
}
}
The above function never returns the hwnd associated with
the procID that is the ID from the created process. Any
ideas?
Does it find the window? If it finds the window, but doesn't
return it, then _HwndProcStruct is messed up somewhere or
discareded too early. If EnumOpenWindows doesn't find the
window, then the window is not top-level window.
P.S. You can open log file just once and then write to it as
needed. No need to reopen it every time. It is a real pain
to see such code.