开发者

Run process in .NET and C++

开发者 https://www.devze.com 2022-12-22 21:02 出处:网络
I search for the function that run programm by path, and working开发者_运维知识库 of main programm is stopped until run second programm. Can i do that by using System.Diagnostics.Process class?look at

I search for the function that run programm by path, and working开发者_运维知识库 of main programm is stopped until run second programm. Can i do that by using System.Diagnostics.Process class?


look at this question


Use this if you want to just use the 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");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号