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

前端 未结 6 1190
轻奢々
轻奢々 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:24

    I don't think there is such a thing. The console window is not accessible to the application. You MIGHT try to iterate the process list looking for your own process name. The Process class IIRC contains a property for the program's main window handle, which might be the console window for console applications - which I'm not sure of.

提交回复
热议问题