Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

addfunction (wtsapi32)
 
.

Err

Summary
This function is meant to query the listeners on the workstation it is invoked from.

C# Signature:

/// <summary>
/// This function is to be called twice.  
/// First time is to get pCount (function returns false with WinErr 122).  
/// Second Time is to get pointer of array (function returns true if successful)
/// Unfortunately this function cannot be used on another machine, unlike [winsta.dll] -> WinStationQueryInformationW ... see Cassia source code for details
/// </summary>
/// <param name="hServer"> Remote Server Handle not supported.  Value must be IntPtr.Zero ( WTS_CURRENT_SERVER_HANDLE ) </param>
/// <param name="pReserved">Value must be IntPtr.Zero</param>
/// <param name="Reserved">Always set to 0</param>
/// <param name="pListeners">A pointer to an array, filled when pCount is greater than 0</param>
/// <param name="pCount">If pListeners is IntPtr.Zero and pCount is 0, calling function will populate pCount</param>
/// <returns></returns>
[DllImport("wtsapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern bool WTSEnumerateListeners([In] IntPtr hServer,
                                         [In] IntPtr pReserved,
                                         [In] uint Reserved,
                                         [Optional] ref IntPtr pListeners,
                                         [In,Out] ref uint pCount);

Alternative Managed API:

//GitHub > Cassia > Impl > NativeMethods.cs
[DllImport("winsta.dll", CharSet = CharSet.Unicode, EntryPoint = "WinStationQueryInformationW", SetLastError = true)]
public static extern int WinStationQueryInformationRemoteAddress(IntPtr hServer, int sessionId,
                                                                 WINSTATIONINFOCLASS information,
                                                                 ref WINSTATIONREMOTEADDRESS buffer,
                                                                 int bufferLength, out int returnedLength);

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions