[英]Why is ShellExecuteEx not returning the process handle?
I am trying to open an image with the following function: 我正在尝试使用以下功能打开图像:
HANDLE openFile(char *path){ // path = "C:\Users\Foo Bar\Code\Test\test.jpg"
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
SHELLEXECUTEINFOW info;
memset(&info, 0, sizeof(info));
info.cbSize = sizeof(info);
info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC ;
info.hwnd = NULL;
info.lpVerb = L"open";
info.lpFile = utf8_toWchar(path);
info.lpParameters = NULL;
info.lpDirectory = NULL;
info.nShow = SW_SHOW;
info.hInstApp = NULL;
if (!ShellExecuteExW(&info)){
System_printLastErrorString(); //never gets here
}
//free((void*)info.lpFile);
CoUninitialize();
return info.hProcess; //this is always NULL
}
The problem is that info.hProcess
is always NULL
despite the fact that the default image editing program is not open and is opened a bit later. 问题是,尽管默认图像编辑程序未打开,但稍后打开,但
info.hProcess
始终为NULL
。
How do I fix this? 我该如何解决?
Side Note: I dont know if this is relevant, but the calling program is a Qt Application. 旁注:我不知道这是否相关,但是调用程序是Qt应用程序。
I ended up calling CreateProcess
myself to the result of AssocQueryString
. 我最终自己给
AssocQueryString
的结果调用CreateProcess
。 This gave me the handle I needed. 这给了我所需的手柄。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.