我需要在win8中的默认应用程序中打开文件并获取它的进程ID。我使用以下代码:
SHELLEXECUTEINFOA ShExecInfo;
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = filePath.c_str();
ShExecInfo.lpParameters = NULL;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteExA(&ShExecInfo);
int pid = GetProcessId(ShExecInfo.hProcess);
它工作正常。但是,当我试图在Metro风格的应用程序(如Microsoft PDF查看器)中打开文件时,文件打开正常,但是pid是0.我怎样才能获得地铁式应用程序的pid?