CString szApp = "rundll32.exe";
CString szParam = "shell32.dll,Control_RunDLL inetcpl.cpl,,3";
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = m_hWnd;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = szApp;
ShExecInfo.lpParameters = szParam;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWNA;
ShExecInfo.hInstApp = AfxGetInstanceHandle();
ShellExecuteEx(&ShExecInfo); CWnd* pWnd = NULL;
while(pWnd == NULL)
{
pWnd = FindWindow(NULL,"Internet ÊôÐÔ");
}
MSG msg;
while (!g_bWait)
{
if (::PeekMessage(&msg,NULL,0,2000,PM_REMOVE))
{
::TranslateMessage(&msg);
if((msg.message == WM_LBUTTONDOWN) ||
(msg.message == WM_NCLBUTTONDBLCLK)||
(msg.message == WM_NCLBUTTONDOWN) )
{
if(::IsWindow(pWnd ->GetSafeHwnd()))
pWnd ->BringWindowToTop();
}
else
{
if(msg.message == WM_PAINT)
{
if(::IsWindow(pWnd ->GetSafeHwnd()))
pWnd ->BringWindowToTop();
::DispatchMessage(&msg);
}
}
}
}
如何能不用FindWindow,通过ShExecInfo取得pWnd;
CString szParam = "shell32.dll,Control_RunDLL inetcpl.cpl,,3";
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = m_hWnd;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = szApp;
ShExecInfo.lpParameters = szParam;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWNA;
ShExecInfo.hInstApp = AfxGetInstanceHandle();
ShellExecuteEx(&ShExecInfo); CWnd* pWnd = NULL;
while(pWnd == NULL)
{
pWnd = FindWindow(NULL,"Internet ÊôÐÔ");
}
MSG msg;
while (!g_bWait)
{
if (::PeekMessage(&msg,NULL,0,2000,PM_REMOVE))
{
::TranslateMessage(&msg);
if((msg.message == WM_LBUTTONDOWN) ||
(msg.message == WM_NCLBUTTONDBLCLK)||
(msg.message == WM_NCLBUTTONDOWN) )
{
if(::IsWindow(pWnd ->GetSafeHwnd()))
pWnd ->BringWindowToTop();
}
else
{
if(msg.message == WM_PAINT)
{
if(::IsWindow(pWnd ->GetSafeHwnd()))
pWnd ->BringWindowToTop();
::DispatchMessage(&msg);
}
}
}
}
如何能不用FindWindow,通过ShExecInfo取得pWnd;
这样可以使用GetWindwo(GW_CHILD)进行筛选
GetWindowThreadProcessId
ZeroMemory(&si,sizeof(si));
si.cb = sizeof(si);
si.wShowWindow = SW_SHOWNA;
si.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
PROCESS_INFORMATION pi;
if (!CreateProcess(NULL,"rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,3",
NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
return; CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
//m_hInternet = NULL;
m_hInternet = NULL;
while(m_hInternet == NULL)
EnumWindows((WNDENUMPROC)EnumWinProc,(LPARAM)pi.dwProcessId);
CString str;
MSG msg;
while (::IsWindow(m_hInternet))
{
if (::PeekMessage(&msg,NULL,0,2000,PM_REMOVE))
{
::TranslateMessage(&msg);
if((msg.message == WM_LBUTTONDOWN) || (msg.message == WM_NCLBUTTONDBLCLK)||
(msg.message == WM_NCLBUTTONDOWN) )
{
if(::IsWindow(m_hInternet))
::BringWindowToTop(m_hInternet);
}
else
{
if(msg.message == WM_PAINT)
{
if(::IsWindow(m_hInternet))
::BringWindowToTop(m_hInternet);
}
::DispatchMessage(&msg);
}
}
}
{
DWORD nID = 0;
GetWindowThreadProcessId(hwnd,&nID);
if((DWORD)lParam == nID)
{
m_hInternet = hwnd;
return FALSE;
}
return TRUE;
}