WTSSendMessageA handle?

Todd Chester 636 Reputation points

Hi All,

Windows 11-pro 22H2

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,

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,072 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 71,866 Reputation points

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

  2. RLWA32 32,156 Reputation points

    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.