Send windows message to a Windows Service

前端 未结 7 1940
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 05:57

Is there any tool to send (mimic) a windows message like \'WM_ENDSESSION\' to a windows service?

OR

How can I send a windows message to a process using C#?

7条回答
  •  悲哀的现实
    2021-02-06 06:32

    If you have the hwnd of a window you can send it messages. The only limitation is that you can't send messages that contain pointers like setting window text.
    Simply call PostMessage() with the value of the hwnd and the message you want to send.
    To find the hwnd you can use spy++.

    I'm not sure how you connect all this to windows services since windows services don't have windows.

提交回复
热议问题