Stuck on GenerateConsoleCtrlEvent in C# with console apps

前端 未结 3 1960
温柔的废话
温柔的废话 2020-12-18 11:48

I\'m having the hardest time trying to get this to work, hoping one of you has done this before.

I have a C# console app that is running a child process which inheri

3条回答
  •  时光说笑
    2020-12-18 12:32

    Not so sure this is a good approach. This only works if the child process is created with the CREATE_NEW_PROCESS_GROUP flag for CreateProcess(). The System.Diagnostics.Process class however does not support this.

    Consider using the return value from the Main() method. There is already a unique value defined in the Windows SDK for Ctrl+C aborts, STATUS_CONTROL_C_EXIT or 0xC000013A. The parent process can get that return code from the Process.ExitCode property.

提交回复
热议问题