How do I get the handle of a console application's window

前端 未结 6 1191
轻奢々
轻奢々 2020-11-27 18:56

Can someone tell me how to get the handle of a Windows console application in C#? In a Windows Forms application, I would normally try this.Handle.

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 19:31

    Not sure it works, but you can try that :

    IntPtr handle = Process.GetCurrentProcess().MainWindowHandle;
    

提交回复
热议问题