|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to signal processHow can you signal Ctrl-C to a managed process (i.e. process is hosting
cmd.exe)? TIA -- William Stacey [MVP] >How can you signal Ctrl-C to a managed process (i.e. process is hosting If I understand the question correctly, you can call>cmd.exe)? GenerateConsoleCtrlEvent(CTRL_C_EVENT). It should work for any console process, managed or not. http://msdn.microsoft.com/library/en-us/dllproc/base/generateconsolectrlevent.asp Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. Thanks Mattias. Know how to get the "dwProcessGroupId ", when all I have is
the Process.Id ? TIA -- William Stacey [MVP] "Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message http://msdn.microsoft.com/library/en-us/dllproc/base/generateconsolectrlevent.aspnews:eLnioJQVGHA.1344@TK2MSFTNGP15.phx.gbl... | | >How can you signal Ctrl-C to a managed process (i.e. process is hosting | >cmd.exe)? | | If I understand the question correctly, you can call | GenerateConsoleCtrlEvent(CTRL_C_EVENT). It should work for any console | process, managed or not. | | Show quote | | | Mattias | | -- | Mattias Sjögren [C# MVP] mattias @ mvps.org | http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com | Please reply only to the newsgroup. Hello, William!
According to docs: " dwProcessGroupId Identifier of the process group to receive the signal. A process group is created when the CREATE_NEW_PROCESS_GROUP flag is specified in a call to the CreateProcess function. The process identifier of the new process is also the process group identifier of a new process group. The process group includes all processes that are descendants of the root process. Only those processes in the group that share the same console as the calling process receive the signal. In other words, if a process in the group creates a new console, that process does not receive the signal, nor do its descendants." Can you describe your scenario? If you have parent process and descendants, then parent process id will be groupId. If there is single process with console then there is no need to specify dwProcessGroupId |
|||||||||||||||||||||||