/// <summary>
        /// Registers the application to receive power setting notifications 
        /// for the specific power setting event.
        /// </summary>
        /// <param name="handle">Handle indicating where the power setting 
        /// notifications are to be sent.</param>
        /// <param name="powerSetting">The GUID of the power setting for 
        /// which notifications are to be sent.</param>
        /// <returns>Returns a notification handle for unregistering 
        /// power notifications.</returns>
        internal static int RegisterPowerSettingNotification(
            SafeWindowHandle handle, Guid powerSetting)
        {
            int outHandle = NativeMethods.RegisterPowerSettingNotification(
                handle, 
                ref powerSetting, 
                0);

            return outHandle;
        }
Пример #2
0
 internal static extern int GetMessage(
     out SafeNativeMethods.MSG lpMsg,
     SafeWindowHandle hWnd,
     uint wMsgFilterMin,
     uint wMsgFilterMax);
Пример #3
0
 internal static extern int RegisterPowerSettingNotification(
     SafeWindowHandle hRecipient,
     ref Guid PowerSettingGuid,
     Int32 Flags);
Пример #4
0
            internal PowerRegWindow()
            {
                // Register the window class.
                del = new SafeNativeMethods.WNDPROC(this.WndProc);
                IntPtr hInst = Marshal.GetHINSTANCE(
                Assembly.GetEntryAssembly().GetModules()[0]);
                SafeNativeMethods.WNDCLASSEX wndclass =
                    new SafeNativeMethods.WNDCLASSEX();

                wndclass.cbSize = (uint)Marshal.SizeOf(
                    typeof(SafeNativeMethods.WNDCLASSEX));
                wndclass.style = 11;
                wndclass.lpfnWndProc = del;
                wndclass.cbClsExtra = 0;
                wndclass.cbWndExtra = 0;
                wndclass.hInstance = hInst;
                wndclass.lpszMenuName = null;
                wndclass.lpszClassName = "MessageWnd2";

                mm = NativeMethods.RegisterClassEx(ref wndclass);
                int hr = Marshal.GetLastWin32Error();
                Marshal.ThrowExceptionForHR(hr);

                // Create the windowless window that provides
                // the message pump needed to receive windows messages.
                _handle = NativeMethods.CreateWindowEx(
                    0x08000000,
                    mm,
                    "mymessagewindow2",
                    0, 0, 0, 0, 0, SafeNativeMethods.HWND_MESSAGE,
                    0, hInst, IntPtr.Zero);

                hr = Marshal.GetLastWin32Error();
                //if (hr == 0)
                //{
                //    throw new Win32Exception("Error creating message pump window.");
                //}
                Marshal.ThrowExceptionForHR(hr);
            }
Пример #5
0
 internal static extern int GetMessage(
     out SafeNativeMethods.MSG lpMsg,
     SafeWindowHandle hWnd,
     uint wMsgFilterMin,
     uint wMsgFilterMax);
Пример #6
0
 internal static extern int RegisterPowerSettingNotification(
         SafeWindowHandle hRecipient,
         ref Guid PowerSettingGuid,
         Int32 Flags);