ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSFinger/Wts.cs
Revision: 710
Committed: 2006-03-24T01:37:37-08:00 (19 years, 3 months ago) by douglas
File size: 1780 byte(s)
Log Message:
I decided to do this in C#, it still has issues right now, and is currently working less than before. SuX0r!

File Contents

# User Rev Content
1 douglas 710 // Douglas Thrift
2     //
3     // CCS Computer Science
4     //
5     // Win32 Terminal Services Wrapper
6    
7     using System;
8     using System.Runtime.InteropServices;
9    
10     public static class Wts
11     {
12     public enum WTS_CONNECTSTATE_CLASS
13     {
14     WTSActive,
15     WTSConnected,
16     WTSConnectQuery,
17     WTSShadow,
18     WTSDisconnected,
19     WTSIdle,
20     WTSListen,
21     WTSReset,
22     WTSDown,
23     WTSInit
24     }
25    
26     public enum WTS_INFO_CLASS
27     {
28     WTSInitialProgram,
29     WTSApplicationName,
30     WTSWorkingDirectory,
31     WTSOEMId,
32     WTSSessionId,
33     WTSUserName,
34     WTSWinStationName,
35     WTSDomainName,
36     WTSConnectState,
37     WTSClientBuildNumber,
38     WTSClientName,
39     WTSClientDirectory,
40     WTSClientProductId,
41     WTSClientHardwareId,
42     WTSClientAddress,
43     WTSClientDisplay,
44     WTSClientProtocolType
45     }
46    
47     [StructLayout(LayoutKind.Sequential)]
48     public class WTS_SESSION_INFO
49     {
50     public uint SessionId;
51     [MarshalAs(UnmanagedType.LPWStr)]
52     public string pWinStationName;
53     public WTS_CONNECTSTATE_CLASS State;
54     }
55    
56     [DllImport("Wtsapi32.dll", EntryPoint = "WTSEnumerateSessionsW")]
57     public static extern bool EnumerateSessions([In] IntPtr hServer, uint reserved, [In] uint Version, [Out] WTS_SESSION_INFO[] ppSessionInfo, [Out] uint pCount);
58    
59     [DllImport("Wtsapi32.dll", EntryPoint = "WTSFreeMemory")]
60     public static extern void FreeMemory([In] WTS_SESSION_INFO[] pMemory);
61    
62     [DllImport("Wtsapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "WTSFreeMemory")]
63     public static extern void FreeMemory([In] string pMemory);
64    
65     [DllImport("Wtsapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "WTSQuerySessionInformationW")]
66     public static extern bool QuerySessionInformation([In] IntPtr hServer, [In] uint SessionId, [In] WTS_INFO_CLASS WTSInfoClass, [Out] string ppBuffer, [Out] uint pBytesReturned);
67     }