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.
How do I fix this?
Side Note: I dont know if this is relevant, but the calling program is a Qt Application.
I ended up calling CreateProcess
myself to the result of AssocQueryString
. This gave me the handle I needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.