int   iRet   =   (int)ShellExecute(NULL,NULL, strURL,   NULL,   NULL,   SW_SHOWMAXIMIZED);  这个iRet的值为 5strURL的值为 http://www.google.com.hk

解决方案 »

  1.   

    ShellExecute(NULL,"open", strURL, NULL, NULL, SW_SHOWMAXIMIZED);  
      

  2.   

    第二个参数是"open"才行,看看MSDN
      

  3.   

    HINSTANCE CUtility::GotoURL(LPCTSTR url, int showcmd)
    {
    TCHAR key[MAX_PATH + MAX_PATH]; // First try ShellExecute()
    HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd); // If it failed, get the .htm regkey and lookup the program
    if ((UINT)result <= HINSTANCE_ERROR) { if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) {
    lstrcat(key, _T("\\shell\\open\\command")); if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) {
    TCHAR *pos;
    pos = _tcsstr(key, _T("\"%1\""));
    if (pos == NULL) {                     // No quotes found
    pos = strstr(key, _T("%1"));       // Check for %1, without quotes
    if (pos == NULL)                   // No parameter at all...
    pos = key+lstrlen(key)-1;
    else
    *pos = '\0';                   // Remove the parameter
    }
    else
    *pos = '\0';                       // Remove the parameter lstrcat(pos, _T(" "));
    lstrcat(pos, url);
    result = (HINSTANCE) WinExec(key,showcmd);
    }
    }
    } return result;
    }
      

  4.   

    不为open也可以的
     加了还是一样的我的程序还是管理员方式打开的...
      

  5.   


    TCHAR lpszCmdLine[] = {_T("\"C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE\" \"http://www.baidu.com/\"")}; 
    STARTUPINFO si = {sizeof(si)};
    PROCESS_INFORMATION pi = {0};
    if(CreateProcess(NULL, lpszCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
    {
    CloseHandle(pi.hThread);
    CloseHandle(pi.hProcess);
    }
    else
    {
    CString str;
    str.Format(_T("%d"), GetLastError());
    AfxMessageBox(str);
    }
      

  6.   

    我只是想知道,为什么用 
    ShellExec 返回代码 5