gpt4 book ai didi

.net - 在 .NET 和 C++ 中运行进程

转载 作者:行者123 更新时间:2023-11-28 08:30:14 25 4
gpt4 key购买 nike

我通过路径搜索运行程序的功能,主程序的工作停止,直到运行第二个程序。我可以使用 System.Diagnostics.Process 类来做到这一点吗?

最佳答案

看看这个question


如果你只想使用 win32 api,请使用它

#include <stdio.h>
#include <Windows.h>

int main(int argc, char ** argv)
{
STARTUPINFO SI;
PROCESS_INFORMATION PI;
memset(&SI,0,sizeof(SI));
memset(&PI,0,sizeof(PI));
SI.cb = sizeof(SI);

//ProcessorCap
if(!CreateProcess(NULL,"Notepad.exe ",NULL,NULL,false,0,NULL,NULL,&SI,&PI))
{
printf("Error %d",GetLastError());
return 1;
}
DWORD ExitCode;
do
{
GetExitCodeProcess(PI.hProcess,&ExitCode);
Sleep(100);
}while (ExitCode == STILL_ACTIVE);
printf("Exited");
}

关于.net - 在 .NET 和 C++ 中运行进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2452576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com