EnumWindows for WinCE 4.20

G

Guest

Hello!

I am trying to get a list of all the process running on WinCE. I first
developed my code on NT (which is working fine) and now I am porting it to
WinCE 4.20. I am using embedded Visual C++ 4 SP2.

My problem is that the callback function is called only once and my program
crashes. No exception seems to be thrown. Do you have some suggestions on
what may be the problem?

My code looks like:

BOOL CALLBACK _EnumProc(HWND hwnd, LPARAM lParam);

void DrvOpen(void)
{
BOOL bFoundProc = FALSE;
...
EnumWindows(_EnumProc, (unsigned long)&bFoundProc);
...
}

BOOL CALLBACK _EnumProc(HWND hwnd, LPARAM lParam)
{
BOOL bContinueEnum = TRUE;

TCHAR pszCaption[2048];
char szProcName[2048];
static unsigned int uiCallCounter = 0;

GetWindowText(hwnd, pszCaption, sizeof(pszCaption));

wtoa( pszCaption, szProcName, 2048 );
_TraceLog( szProcName, FALSE, FALSE ); // bCheckLastError, bOverwriteFile

....

return bContinueEnum;
}

Thank you in advance!

Frederic.
 
D

David Lowndes

My problem is that the callback function is called only once and my program
crashes. No exception seems to be thrown. Do you have some suggestions on
what may be the problem?

Frederic,

A shot in the dark...

Is the stack allocation large for a CE device perhaps?
TCHAR pszCaption[2048];
char szProcName[2048];
This:

GetWindowText(hwnd, pszCaption, sizeof(pszCaption));

ought to be:

GetWindowText(hwnd, pszCaption, 2048/*_countof(pszCaption)*/);

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top