本文介绍了SW_HIDE在Windows 8和IE10上无法与ShellExecute一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SW_HIDE在Windows 8和Internet Explorer 10上不能与ShellExecute一起使用.任何人在同一方面都没有任何线索.
我尝试了以下代码.
Hi,
SW_HIDE doesn''t work with ShellExecute on windows 8 and Internet Explorer 10. Does any one has any clue on the same.
I tried the below code.
HINSTANCE hInstance = ShellExecute(NULL, _T("open"),_T("IExplore.exe"), _T("www.google.com"), CString(szTemp), SW_HIDE);
感谢您提供任何帮助
Any help is appreciated
推荐答案
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
si.cb = sizeof(cb);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
if(::CreateProcess(
NULL, // LPCTSTR lpApplicationName,
_T("\"C:\\Program File\\Internet Explorer\\IExplore.exe\" http://www.google.com"), // LPTSTR lpCommandLine,
NULL, // LPSECURITY_ATTRIBUTES lpProcessAttributes,
NULL, //LPSECURITY_ATTRIBUTES lpThreadAttributes,
FALSE, //bInheritHandles,
NULL, //DWORD dwCreationFlags,
NULL, //LPVOID lpEnvironment,
NULL, //LPCTSTR lpCurrentDirectory,
&si, //LPSTARTUPINFO lpStartupInfo,
&pi, //LPPROCESS_INFORMATION lpProcessInformation))
{
// if window is still visible - brute-force attack
::WaitForInputIdle(pi.hProcess, 10000);
// find the main window
DWORD dwProcessId = 0;
HWND hWndMain = NULL;
HWND hWnd = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
while(NULL != hWnd)
{
DWORD dwThreadId =
::GetWindowThreadProcessId(hWnd, &dwProcessId);
if((dwThreadId == processInfo.dwThreadId) &&
(dwProcessId == processInfo.dwProcessId))
{
const int nMaxCount = 256;
TCHAR pszClassName[nMaxCount];
::GetClassName(hWnd, pszClassName, nMaxCount);
if(!_tcsicmp(pszClassName, _T("find out the window class of IE using spy")))
{
hWndMain = hWnd;
break;
}
}
hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
}
if(hWndMain) ::ShowWindow(hWndMain, SW_HIDE);
::CloseHandle(pi.hProcess);
::CloseHandle(pi.hThread);
}
HINSTANCE hInstance;
hInstance = ShellExecute(NULL, TEXT("open"), TEXT("http://www.google.com.sa/"), NULL, NULL, SW_HIDE);
该代码调用默认的Web浏览器,许多人使用不同的浏览器,然后打开该URL.
This code invokes the default web browser, many people use different browsers, and opens that URL.
这篇关于SW_HIDE在Windows 8和IE10上无法与ShellExecute一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!