Beispiel #1
0
        /// <summary>
        ///     Retrieve the specified struct
        /// </summary>
        /// <typeparam name="T">type of the struct to return</typeparam>
        /// <returns>struct of type T</returns>
        public static T QuerySessionInformation <T>(InfoClasses infoClass)
            where T : struct
        {
            var expectedType = typeof(T);

            if (!WFQuerySessionInformation(CurrentServer, CurrentSession, infoClass, out var addr, out _))
            {
                return(default);
Beispiel #2
0
        /// <summary>
        ///     Retrieve a string value from the WFQuerySessionInformation
        /// </summary>
        /// <returns>string with the value</returns>
        public static string QuerySessionInformation(InfoClasses infoClass)
        {
            IntPtr addr;
            int    returned;

            if (!WFQuerySessionInformation(CurrentServer, CurrentSession, infoClass, out addr, out returned))
            {
                return(null);
            }
            try
            {
                return(Marshal.PtrToStringAuto(addr));
            }
            finally
            {
                WFFreeMemory(addr);
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Retrieve the specified struct
        /// </summary>
        /// <typeparam name="T">type of the struct to return</typeparam>
        /// <returns>struct of type T</returns>
        public static T QuerySessionInformation <T>(InfoClasses infoClass)
            where T : struct
        {
            var    expectedType = typeof(T);
            IntPtr addr;
            int    returned;

            if (!WFQuerySessionInformation(CurrentServer, CurrentSession, infoClass, out addr, out returned))
            {
                return(default(T));
            }
            try
            {
                return((T)Marshal.PtrToStructure(addr, expectedType));
            }
            finally
            {
                WFFreeMemory(addr);
            }
        }
Beispiel #4
0
 private static extern bool WFQuerySessionInformation(IntPtr hServer, int iSessionId, InfoClasses infotype, out IntPtr ppBuffer, out int pBytesReturned);