WTSSendMessageA handle?

Todd Chester 646 Reputation points
2022-11-19T07:53:45.383+00:00

Hi All,

Windows 11-pro 22H2
https://learn.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtssendmessagea

WTSSendMessageA states:

[in] hServer

A handle to an RD Session Host server. Specify a handle opened by the WTSOpenServer function, or specify WTS_CURRENT_SERVER_HANDLE to indicate the RD Session Host server on which your application is running.

If I choose NOT to use "WTS_CURRENT_SERVER_HANDLE", how to I get my "handle to an RD Session Host server"?

Many thanks,
-T

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 81,636 Reputation points
    2022-11-19T08:26:26.257+00:00

    If you want to send a message to your computer, call WTSOpenServer with the name of your computer (returned from GetComputerName)


  2. RLWA32 40,286 Reputation points
    2022-11-20T22:40:18.553+00:00

    We've been through this several times already. Your Raku function will never work properly from the task scheduler which runs a process in session 0 until it uses WTSEnumerateSessions.