private T QuerySessionInfo <T>(WtsSessionInfoClass info) { IntPtr retval; Int32 byteCount; using (var cookie = _session.Server.OpenServer()) { if (!NativeMethods.WTSQuerySessionInformation( cookie.Handle, _session.Id, info, out retval, out byteCount)) { return(default(T)); } } if (typeof(T) == typeof(String)) { return((T)(Object)Marshal.PtrToStringUni(retval)); } else { return((T)Marshal.PtrToStructure(retval, typeof(T))); } }
public static extern bool WTSQuerySessionInformation( IntPtr hServer, Int32 SessionId, WtsSessionInfoClass info, out IntPtr ppBuffer, out Int32 pBytesReturned);
public static extern bool WTSQuerySessionInformation( IntPtr hServer, Int32 SessionId, WtsSessionInfoClass info, out IntPtr ppBuffer, out Int32 pBytesReturned);