我正在尝试以编程方式启动 explorer.exe,但我没有任何运气。
这是我的代码:
cout << pName << "died, lets restart it." << endl;
STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(startupInfo);
PROCESS_INFORMATION processInformation;
if(CreateProcess(pName, NULL, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &startupInfo, &processInformation) == 0){
cout << "Error starting " << pName << ": " << GetLastError() << endl;
}
pName 是 explorer.exe
有人可以告诉我我做错了什么吗?我收到错误代码“2”,即 ERROR_FILE_NOT_FOUND
最佳答案
第一个参数是应用名称;第二个是命令行。尝试将“explorer.exe”指定为第二个参数。
查看此 MSDN article :
lpApplicationName [in, optional]
The name of the module to be executed. This module can be a Windows-based application. It can be some other type of module (for example, MS-DOS or OS/2) if the appropriate subsystem is available on the local computer.
The string can specify the full path and file name of the module to execute or it can specify a partial name. In the case of a partial name, the function uses the current drive and current directory to complete the specification. The function will not use the search path. This parameter must include the file name extension; no default extension is assumed.
关于c++ - 如何通过 C++ 启动 explorer.exe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/865395/