1
我想通过CreateProcess API打开Chrome浏览器。我无法这样做。未能通过CreateProcess API打开Chrome浏览器
我试着这样做:
string commandLine = "\"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe\"";
commandLine += " -- ";
commandLine += pURLinfo->szURL;
CreateProcess(commandLine.c_str(), NULL, NULL, NULL, FALSE,
CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, &processInformation);
的CreateProcess返回错误123 也许有另一种方式来打开它。 (我不是在谈论ShellExecute)。
更新:我的代码现在看起来像这样,但我仍然无法运行chrome。
STARTUPINFOA si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
// Start the child process.
if (!CreateProcessA("C:\\Program Files(x86)\\Google\\Chrome\\Application\\chrome.exe", // No module name (use command line)
NULL,
NULL, // Process handle not inheritable
NULL, // Thread handle not inhberitable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
)
{
printf("CreateProcess failed (%d).\n", GetLastError());
getchar();
return 0;
}
在这里你去https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs删除不需要的报价。 85).aspx aaa,它是ERROR_INVALID_NAME。我相信你知道该怎么做。 – Pyjong
错误123是ERROR_INVALID_NAME(“文件名,目录名称或卷标语法不正确。”)。确保你会提供正确的路径。 –
顺便说一句,可以是dup http://stackoverflow.com/questions/15469666/invoking-nvcc-exe-using-createprocess –