BOOL CALLBACK EnumFunc(HWND hMywnd, LPARAM lParam );
HWND hWnd;
BOOL CALLBACK EnumFunc(HWND hMywnd, LPARAM lParam )
{
char szBuffer[_MAX_PATH];
::GetWindowText(hMywnd,szBuffer,_MAX_PATH - 1);
if(strstr(szBuffer,(char *)lParam)) {
CWnd *pFacilityWnd;
pFacilityWnd = CWnd::FindWindow(NULL,szBuffer);
if (pFacilityWnd != NULL) {
pFacilityWnd->SendMessage(WM_CLOSE);
}
}
return true;
}
char * szTitle ="myapp";
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
::EnumWindows(EnumFunc, (LPARAM)szTitle);
}
return nRetCode;
}
"EYutz" <ejyutz@_NOTSO_hotmail.com> wrote in message
news:qpBF7.16669$jP3.4...@e3500-atl1.usenetserver.com...
> Greetings,
> I need a simple example of the use of EnumWindows and EnumWindowsProc.
I
> have used FindWindow and SendMessage to close a window, but this does not
> work when I dont know the whole "name" of the window (they are all
> basically: myapp 123456789; myapp 212345678; ect. Everything I have found
is
> either a function definition or the code is part of a large program as
part
> of different classes or functions.
>
> Any hints would be greatly appreciated.
>
> Ed Yutz
>
>
>