::EnumWindows((WNDENUMPROC)EnumWindowsProc,NULL)
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)
{
if(::IsWindow(hwnd)&&::IsWindowVisible(hwnd))
{
char
szTitle[256];
TCHAR
szBuf[256];
ZeroMemory(szTitle,256);
GetClassName(hwnd,
szBuf,
256
);
GetWindowText(hwnd,szTitle,256);
//
CabinetWClass是explorer的类名
if(lstrlen(szTitle)
&&
IsWindowVisible(hwnd) && strcmp("CabinetWClass",szBuf)==0)
{
AfxMessageBox(szTitle); //AfxMessageBox(szBuf);
//::SendMessage(hwnd,WM_CLOSE,0,0);
::PostMessage(hwnd,WM_CLOSE,0,0);//xp
}
return TRUE;
}
return FALSE;
}