Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than wtsapi32, prefix the name with the module name and a period.
<DllImport("wtsapi32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Private Shared Function WTSOpenServer(ByVal pServerName As String) As IntPtr
End Function
User-Defined Types:
None.
Notes:
As always, only do SetLastError=true if you actually intend to call GetLastError.
public int SessionId;
public string pWinStationName;
public WTS_CONNECTSTATE_CLASS State;
}
public enum WTS_CONNECTSTATE_CLASS
{
/// <summary>
/// user is logged on to the WinStation.
/// </summary>
WTSActiveWTSActiveA,
/// <summary>
/// The WinStation is connected to the client.
/// </summary>
WTSConnectedWTSConnected,
/// <summary>
/// The WinStation is in the process of connecting to the client.
/// </summary>
WTSConnectQueryWTSConnectQuery,
/// <summary>
/// The WinStation is shadowing another WinStation.
/// </summary>
WTSShadowWTSShadow,
/// <summary>
/// The WinStation is active but the client is disconnected.
/// </summary>
WTSDisconnectedWTSDisconnected,
/// <summary>
/// The Win Station is waiting for a client to connect.
/// </summary>
WTSIdleWTSIdle,
/// <summary>
/// The WinStation is listening for a connection. A listener session waits for requests for new client connections.
/// No user is logged on a listener session. A listener session cannot be reset, shadowed, or changed to a regular client session.
/// </summary>
WTSListenWTSListen,
/// <summary>
/// The WinStation is being reset.
/// </summary>
WTSResetWTSReset,
/// <summary>
/// The WinStation is down due to an error.
/// </summary>
WTSDownWTSDown,
/// <summary>
/// The WinStation is initializing.
/// </summary>
WTSInitWTSInit
}
public WTS_SESSION_INFO[] GetSessions(string serveName)
{
WTS_SESSION_INFO[] sessionInfos;
int Count=0;
IntPtr hServer = new IntPtr(0);
hServer = WTSOpenServer(serveName);
if(hServer == IntPtr.Zero)
{
int ret = Marshal.GetLastWin32Error();
string msg = string.Format("\nError: [{0}] {1}\n", ret, GetErrorMessage(ret));
throw new ApplicationException(msg);
}
IntPtr ppSessionInfos = new IntPtr(0);
int sizeOfSessionInfo = Marshal.SizeOf(typeof(WTS_SESSION_INFO));
WTSEnumerateSessions(hServer, 0, 1,out ppSessionInfos, ref Count);
sessionInfos = new WTS_SESSION_INFO[Count];
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
TODO - a short description
3/16/2007 8:17:31 AM - -63.69.129.2
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).