Ejemplo n.º 1
0
        /// <summary>
        /// Creates window that would receive plug in/out device events
        /// </summary>
        /// <returns></returns>
        IntPtr CreateReceiverWnd()
        {
            IntPtr wndHnd = IntPtr.Zero;



            m_wnd_proc_delegate = CustomWndProc;

            // Create WNDCLASS
            Native.WNDCLASS wind_class = new Native.WNDCLASS();
            wind_class.lpszClassName = NOTIFICATION_WND_CLS;
            wind_class.lpfnWndProc   = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(m_wnd_proc_delegate);

            UInt16 class_atom = Native.RegisterClassW(ref wind_class);

            int last_error = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

            if (class_atom == 0 && last_error != ERROR_CLASS_ALREADY_EXISTS)
            {
                Exception e = new System.Exception("Could not register window class");

                UnityEngine.Debug.LogException(e);

                return(IntPtr.Zero);
            }


            try
            {
                // Create window
                wndHnd = Native.CreateWindowExW(
                    0,
                    wind_class.lpszClassName,
                    String.Empty,
                    0,
                    0,
                    0,
                    0,
                    0,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero
                    );
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }


            return(wndHnd);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates window that would receive plug in/out device events
        /// </summary>
        /// <returns></returns>
        IntPtr CreateReceiverWnd()
        {
            IntPtr wndHnd = IntPtr.Zero;

            m_wnd_proc_delegate = CustomWndProc;

            // Create WNDCLASS
            Native.WNDCLASS wind_class = new Native.WNDCLASS();
            wind_class.lpszClassName = NOTIFICATION_WND_CLS;
            wind_class.lpfnWndProc = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(m_wnd_proc_delegate);

            UInt16 class_atom = Native.RegisterClassW(ref wind_class);

            int last_error = System.Runtime.InteropServices.Marshal.GetLastWin32Error();

            if (class_atom == 0 && last_error != ERROR_CLASS_ALREADY_EXISTS)
            {
                Exception e = new System.Exception("Could not register window class");

                UnityEngine.Debug.LogException(e);

                return IntPtr.Zero;
            }

            try
            {
                // Create window
                wndHnd = Native.CreateWindowExW(
                    0,
                    wind_class.lpszClassName,
                    String.Empty,
                    0,
                    0,
                    0,
                    0,
                    0,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero
                    );
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }

            return wndHnd;
        }