コード例 #1
0
 private static extern uint CallNtPowerInformation(
     PowerIinformationLevel InformationLevel,
     IntPtr lpInputBuffer,
     int nInputBufferSize,
     IntPtr result,
     int nOutputBufferSize
     );
コード例 #2
0
        private static T Wrapper <T>(PowerIinformationLevel informationLevel)
        {
            int    size    = Marshal.SizeOf <T>();
            IntPtr typePtr = Marshal.AllocCoTaskMem(size);

            uint status = CallNtPowerInformation(informationLevel, IntPtr.Zero, 0, typePtr, size);

            if (status != STATUS_SUCCESS)
            {
                return(default(T));
            }

            return(Marshal.PtrToStructure <T>(typePtr));
        }