【发布时间】:2021-11-21 20:49:40
【问题描述】:
尝试遵循此示例: https://devblogs.microsoft.com/oldnewthing/20040520-00/?p=39243
void ShellExecuteFromExplorer(PCWSTR pszFile, PCWSTR pszParameters = nullptr, PCWSTR pszDirectory = nullptr, PCWSTR pszOperation = nullptr, int nShowCmd = SW_SHOWNORMAL)
{
CComPtr<IShellFolderViewDual> spFolderView;
GetDesktopAutomationObject(IID_PPV_ARGS(&spFolderView));
CComPtr<IDispatch> spdispShell;
spFolderView->get_Application(&spdispShell);
CComQIPtr<IShellDispatch2>(spdispShell)
->ShellExecute(CComBSTR(pszFile),
CComVariant(pszParameters ? pszParameters : L""),
CComVariant(pszDirectory ? pszDirectory : L""),
CComVariant(pszOperation ? pszOperation : L""),
CComVariant(nShowCmd));
}
在这种情况下,我如何从ShellExecute 启动的进程中检索pid?
【问题讨论】:
-
这是 ATL 吗? -- --
-
您需要从资源管理器执行什么流程?为什么需要它 pid ?你真正的目标是什么?
-
@RbMm "你需要从资源管理器执行进程吗?" -
IShellDispatch2::ShellExecute()可用于launch an unelevated process from an elevated process(我知道你已经知道了) -
是的,这就是@RemyLebeau