예제 #1
0
 public static extern int RegisterClassEx(
     ref SafeNativeMethods.WNDCLASSEX wndcls);
예제 #2
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);
            }