public static WINSTATIONINFORMATIONW GetWinStationInformation(int sessionId) { var retLen = 0; var wsInfo = new WINSTATIONINFORMATIONW(); if ( WinStationQueryInformation(IntPtr.Zero, sessionId, (int)WINSTATIONINFOCLASS.WinStationInformation, ref wsInfo, Marshal.SizeOf(typeof(WINSTATIONINFORMATIONW)), ref retLen) != 0) { return(wsInfo); } throw new Win32Exception(); }
static extern int WinStationQueryInformation(IntPtr hServer, int sessionId, int information, ref WINSTATIONINFORMATIONW buffer, int bufferLength, ref int returnedLength);