TCHAR szFile[128]; 
wsprintf(szFile, "Tencent://Message/?Menu=Yes&Exe=QQ&Uin=%s", "123456"); SHELLEXECUTEINFO ShExecInfo; 
ZeroMemory(&ShExecInfo, sizeof(SHELLEXECUTEINFO)); 
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); 
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; 
ShExecInfo.hwnd = NULL; 
ShExecInfo.lpVerb = NULL; 
ShExecInfo.lpFile = szFile; 
ShExecInfo.lpParameters = NULL; 
ShExecInfo.lpDirectory = NULL; 
ShExecInfo.nShow = SW_SHOWNORMAL; 
ShExecInfo.hInstApp = NULL; 
if(ShellExecuteEx(&ShExecInfo)) 

TCHAR s[256]; 
wsprintf(s, "%d", ShExecInfo.hProcess); 
MessageBox(0, s, "a", 0); 

================================ 
运行可以打开QQ临时对话框,但进程句柄却显示为0,而打开其他应用程序(例如:ShExecInfo.lpFile="C:\\Program Files\\Tencent\\QQ\\QQ.exe"),却可以取得进程句柄?不知为什么,请大家帮助。

解决方案 »

  1.   

    msdn中说,即使fMask设成SEE_MASK_NOCLOSEPROCESS, hProcess 也可能是 NULL ,如果没有进程被创建的话. For example, if a document to be launched is a URL and an instance of Microsoft® Internet Explorer is already running, it will display the document. No new process is launched, and hProcess will be NULL.
    不知道是否和这个原因类似