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

尝试以下操作:

Try this:

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);
}


我不知道szTemp的用途,但是如果您要打开网页,只需键入:

I can''t tell what szTemp is used for, but If you are trying to open a web page, just simply type:

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.