使用带有相对路径的 CreateProcess
是否可以传递相对路径来创建我的子进程? 该代码可以编译,但会出现错误,因为我使用的是相对路径。
void Cminivideo3App::creerChildProcess(void)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
int retvalue = CreateProcess( TEXT("\..\Debug\traitement.exe"), // No module name (use command line)
NULL, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
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
);
int lastError = GetLastError();
}
Is it possible to pass a relative path to create my child process?
This code will compile, but it gives an error because I'm using a relative path.
void Cminivideo3App::creerChildProcess(void)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
int retvalue = CreateProcess( TEXT("\..\Debug\traitement.exe"), // No module name (use command line)
NULL, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
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
);
int lastError = GetLastError();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一些事情:
\
是当前驱动器的根文件夹,而不是相对路径。TEXT("..\\Debug\\traitement.exe")
。Couple things:
\
is the root folder of the current drive, not a relative path.TEXT("..\\Debug\\traitement.exe")
.对我来说,它看起来不像相对路径。
\
是当前驱动器的根文件夹。It does not look like a relative path to me.
\
is the root folder of the current drive.