Get the handle and write to the console that launched our process

前端 未结 4 1652
清歌不尽
清歌不尽 2021-02-06 16:54

How could I write to the standard output of some already open console? I find the console I need with this piece of code:

    IntPtr ptr = GetForegroundWindow();         


        
4条回答
  •  借酒劲吻你
    2021-02-06 17:07

    A system process is uniquely identified on the system by its process identifier. Like many Windows resources, a process is also identified by its handle, which might not be unique on the computer. A handle is the generic term for an identifier of a resource. The operating system persists the process handle, which is accessed through the Process.Handle property of the Process component, even when the process has exited. Thus, you can get the process's administrative information, such as the Process.ExitCode (usually either zero for success or a nonzero error code) and the Process.ExitTime. Handles are an extremely valuable resource, so leaking handles is more virulent than leaking memory.

    This is not the exact answer to ur questions , but it helps u to understand the basic thing actually.

提交回复
热议问题