public void RegisterClass(ClassCreateParams ccp) { WNDCLASSEX wc = new WNDCLASSEX() { cbSize = Marshal.SizeOf(typeof(WNDCLASSEX)), lpszClassName = ccp.Name, lpfnWndProc = ccp.WndProc, style = (int)ccp.Style, cbClsExtra = ccp.ExtraClassBytes, cbWndExtra = ccp.ExtraWindowBytes, hbrBackground = ccp.BackgroundBrush, hInstance = Marshal.GetHINSTANCE(this.GetType().Module) }; if (RegisterClassEx(ref wc) != 0) { throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()); } }