TO In355HZ 我把代码加在OnOK()函数中,编译结果是: D:\test\ieclose\iecloseDlg.cpp(178) : error C2440: '=' : cannot convert from 'class CWnd *' to 'struct HWND__ *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast D:\test\ieclose\iecloseDlg.cpp(181) : error C2660: 'PostMessageA' : function does not take 4 parameters Error executing cl.exe.
{
DWORD pid;
DWORD tid;
HWND hwnd;
}PROC_WINDOWS;
BOOL CALLBACK ListMsPaintWindow(
HWND hwnd, // handle to parent window
LPARAM lParam // application-defined value
)
{
PROC_WINDOWS *p;
DWORD pid, tid; p = (PROC_WINDOWS *) lParam;
tid = GetWindowThreadProcessId(hwnd, &pid);
if(pid == p->pid)
{
p->hwnd = hwnd;
p->tid = tid;
return FALSE;
} return TRUE;
}//下面是应用代码
void find_spe_win()
{
PROC_WINDOWS proc_windows; memset(&proc_windows, 0, sizeof(proc_windows));
proc_windows.pid = pi.dwProcessId;
EnumWindows(ListMsPaintWindow, (LPARAM)&proc_windows); if(proc_windows.tid){
hookmsg(pi.dwProcessId, proc_windows.tid);
}
}
http://www.codeproject.com/tools/another_enum_viewer.asp
http://www.codeproject.com/tools/minispy.asp
另外,楼上的代码好象没有实现判断该窗口是否属于IE,
另外代码hookmsg(pi.dwProcessId, proc_windows.tid);是关窗口的意思吗?
while (hWnd = FindWindow("IEFrame", NULL))
{
PostMessage(hWnd, WM_CLOSE, NULL, NULL);
}
我把代码加在OnOK()函数中,编译结果是:
D:\test\ieclose\iecloseDlg.cpp(178) : error C2440: '=' : cannot convert from 'class CWnd *' to 'struct HWND__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\test\ieclose\iecloseDlg.cpp(181) : error C2660: 'PostMessageA' : function does not take 4 parameters
Error executing cl.exe.
while (hWnd = ::FindWindow("IEFrame", NULL))
{
// 最好检查一下,如果某个窗口不响应没有及时关闭,这段代码就死循环了。
::SendMessage(hWnd, WM_CLOSE, NULL, NULL);
}
1、上面这段程序能找到"IEFrame"窗口,但发WM_CLOSE不起作用,而对于"Notepad"却完全正常;
2、我发现IE打开的第一个窗口为"IEFrame",接下去的子窗口好象都为"CabinetWClass";
3、我以前试过pWnd->SendMessage(WM_CLOSE,0,0);是可以成功(对IE)的,其中定义为CWnd* pWnd,但我不知道怎么得到pWnd?多谢,再帮帮忙!