using System;
using System.Runtime.InteropServices;
#region WTS 세션 정보 질의하기 - WTSQuerySessionInformationW(serverHandle, sessionID, wtsInfoClass, bufferHandle, byteCountReturned)
/// <summary>
/// WTS 세션 정보 질의하기
/// </summary>
/// <param name="serverHandle">서버 핸들</param>
/// <param name="sessionID">세션 ID</param>
/// <param name="wtsInfoClass">WTS 정보 클래스</param>
/// <param name="bufferHandle">버퍼 핸들</param>
/// <param name="byteCountReturned">반환 바이트 카운트</param>
/// <returns>처리 결과</returns>
[DllImport("wtsapi32", CharSet = CharSet.Unicode)]
private static extern bool WTSQuerySessionInformationW
(
IntPtr serverHandle,
uint sessionID,
WTS_INFO_CLASS wtsInfoClass,
ref IntPtr bufferHandle,
ref uint byteCountReturned
);
#endregion
/// <summary>
/// 배정도 정수
/// </summary>
[StructLayout(LayoutKind.Explicit)]
public struct LARGE_INTEGER
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
/// <summary>
/// 하위 파트
/// </summary>
[FieldOffset(0)]
public uint LowPart;
/// <summary>
/// 상위 파트
/// </summary>
[FieldOffset(4)]
public int HighPart;
/// <summary>
/// 쿼드 파트
/// </summary>
[FieldOffset(0)]
public long QuadPart;
#endregion
}
/// <summary>
/// WTS 정보 확장 레벨 1 (유니코드)
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTSINFOEX_LEVEL1_W
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
/// <summary>
/// 세션 ID
/// </summary>
public int SessionID;
/// <summary>
/// 세션 상태
/// </summary>
public WTS_CONNECTSTATE_CLASS SessionState;
/// <summary>
/// 세션 플래그
/// </summary>
public int SessionFlag;
/// <summary>
/// WIN 스테이션명
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 33)]
public string WinStationName;
/// <summary>
/// 사용자명
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)]
public string UserName;
/// <summary>
/// 도메인명
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 18)]
public string DomainName;
/// <summary>
/// 로그온 시간
/// </summary>
public LARGE_INTEGER LogonTime;
/// <summary>
/// 연결 시간
/// </summary>
public LARGE_INTEGER ConnectTime;
/// <summary>
/// 연결 중단 시간
/// </summary>
public LARGE_INTEGER DisconnectTime;
/// <summary>
/// 최근 입력 시간
/// </summary>
public LARGE_INTEGER LastInputTime;
/// <summary>
/// 현재 시간
/// </summary>
public LARGE_INTEGER CurrentTime;
/// <summary>
/// 수신 바이트 카운트
/// </summary>
public uint IncomingByteCount;
/// <summary>
/// 송신 바이트 카운트
/// </summary>
public uint OutgoingByteCount;
/// <summary>
/// 수신 프레임 카운트
/// </summary>
public uint IncomingFrameCount;
/// <summary>
/// 송신 프레임 카운트
/// </summary>
public uint OutgoingFrameCount;
/// <summary>
/// 수신 압축 바이트 카운트
/// </summary>
public uint IncomingCompressedByteCount;
/// <summary>
/// 송신 압축 바이트 카운트
/// </summary>
public uint OutgoingCompressedByteCount;
#endregion
}
/// <summary>
/// WTS 정보 확장 레벨 (유니코드)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct WTSINFOEX_LEVEL_W
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
/// <summary>
/// WTS 정보 확장 레벨 1
/// </summary>
public WTSINFOEX_LEVEL1_W WTSInfoExLevel1;
#endregion
}
/// <summary>
/// WTS 정보 확장 (유니코드)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct WTSINFOEXW
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Public
#region Field
/// <summary>
/// 레벨
/// </summary>
public int Level;
/// <summary>
/// 데이터
/// </summary>
public WTSINFOEX_LEVEL_W Data;
#endregion
}