通过EnumWindows,FindWindow
typedef struct __Enum_Window_Para__
{
HWND hwnd;
CString sTitle;
}ENUMWINDOWPARA,*PENUMWINDOWPARA;
BOOL CALLBACK EnumWindowProc(HWND hwnd, LPARAM lParam)
{
ENUMWINDOWPARA* mPara = (ENUMWINDOWPARA*)lParam;
char buffer[256]={0};
::GetWindowText(hwnd,buffer,256);
CString sTitle = CString(buffer);
sTitle.MakeLower();
mPara->sTitle.MakeLower();
if(sTitle.Find(mPara->sTitle)>-1)
{
mPara->hwnd = hwnd;
return FALSE;
}
return TRUE;
}
ENUMWINDOWPARA mPara;
mPara.sTitle = _T("macromedia flashpaper");
::EnumWindows(EnumWindowProc,(LPARAM)&mPara);
if(mPara.hwnd != NULL)
{
}