我正在使用 CreateProcessW 函数来创建一个进程。在这个函数中,传递第一个参数,即 lpApplicationName 和一些空格,如下所示:
在下面的路径(pszExePath)中有空格,因为这个过程没有创建。
pszExePath = L"C:\\Program Files\\Common Files\\Installer\\emrinst.exe";
我尝试使用以下几行来修剪空间,但我仍然面临这个问题。
pszExePath = L"\"";
pszExePath += L"C:\\Program Files\\Common Files\\Installer\\emrinst.exe";
pszExePath += L"\"";
如何从 CreateProcessW 函数的 lpApplicationName 中修剪空间?
以下是更新后的代码:
pszExePath = L"C:\\Program Files\\Common Files\\Installer\\emrinst.exe";
strCommandLine = "C:\\Testfolder\\Program Files\\Common Files\\Apps\\emarmain\\emr-test_folder\\Millinnium Files\\test\\test.inf";
std::wstring strFullPath = L"";
strFullPath += pszExePath;
strFullPath += pszCmdLine;
dwExitCode = ::CreateProcessW(NULL, (LPWSTR)strFullPath.c_str(),
0, 0, FALSE, NORMAL_PRIORITY_CLASS, 0,
pszCurrentDirectory, &si, &pi);
我仍然收到错误,我认为它超过了第二个参数“lpCommandLine”的 32,768 个字符的大小。有什么办法可以增加尺寸吗?而且我的代码片段是否正确?