예제 #1
0
        private static bool IsClassRegistered()
        {
            // Get instance handle
            IntPtr instance = Marshal.GetHINSTANCE(typeof(MessageWindow).Module);

            // Set class name
            string class_name = "WSUtilWindow";

            // Set up struct
            User.WNDCLASSEX window_class = new User.WNDCLASSEX {
                cbSize = (uint)Marshal.SizeOf(typeof(User.WNDCLASSEX))
            };

            // Return if class exists
            return(User.GetClassInfoEx(instance, class_name, ref window_class));
        }
예제 #2
0
        private static void RegisterClass()
        {
            // Set up struct
            User.WNDCLASSEX window_class = new User.WNDCLASSEX();

            window_class.cbSize        = (uint)Marshal.SizeOf(typeof(User.WNDCLASSEX));
            window_class.style         = User.ClassStyles.None;
            window_class.lpfnWndProc   = new User.WindowProc(User.DefWindowProc);
            window_class.cbClsExtra    = 0;
            window_class.cbWndExtra    = 0;
            window_class.hInstance     = Marshal.GetHINSTANCE(typeof(MessageWindow).Module);
            window_class.hIcon         = IntPtr.Zero;
            window_class.hIconSm       = IntPtr.Zero;
            window_class.lpszMenuName  = String.Empty;
            window_class.lpszClassName = "WSUtilWindow";

            // Register class
            if (User.RegisterClassEx(ref window_class) == 0)
            {
                throw new Exception("Could not register class.");
            }
        }