Send windows message to a Windows Service

前端 未结 7 2027
隐瞒了意图╮
隐瞒了意图╮ 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:40

    I don't know if this is a similar handle, I doubt it, but someone could let me know if it is, but you can get a Process handle, which means you could get the process using Process.GetProcessesByName("MyAppName");, althought don't rely on this as I don't think that it will get the handle that you are after. Just a suggestion.

    Actually this method will work...you just need to access the 'MainWindowHandle' property of the process object. For Instance...

    Process myProcess;
    Int handle;
    myProcess = Process.GetProcessesByName("MyAppName");
    handle = myProcess.MainWindowHandle;
    

提交回复
热议问题