【发布时间】:2015-12-28 08:52:12
【问题描述】:
我正在使用 ShellExecuteEx(&ShExecInfo) 启动 .exe ,当 .exe 从我的应用程序启动时,窗口焦点会在很短的时间内转移到先前打开的应用程序(如 windows explore)大约 1 秒,之后它返回到.exe。我希望我的注意力应该放在 exe 上,而不是在短时间内访问任何应用程序。
参考代码:
SHELLEXECUTEINFO ShExecInfo;
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = mainWndHWnd;
ShExecInfo.lpVerb = L"open";
ShExecInfo.lpFile = L"abc.exe";
ShExecInfo.lpParameters = buffer;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWNA;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
【问题讨论】:
-
我试过 ShExecInfo.nShow = SW_SHOWNORMAL;但不能解决我的问题
-
这取决于你的 abc.exe。检查它是否快速退出。这可能是它立即退出然后 Windows 将焦点移到上一个窗口的情况。
-
我的exe是一个c#表单应用程序,它会保留很长时间。焦点也会在短时间内转到先前打开的应用程序并立即返回到 exe。当我关闭 exe 时,焦点来到父应用程序,因为它在父应用程序上是模态的。
标签: visual-c++ shellexecute shellexecuteex