Esempio n. 1
0
        public void RegisterHidEvent
        (
            IntPtr r_HANDLE
        )
        {
            DEV_BROADCAST_DEVICE_INTERFACE devBoardcastDeviceInterface = new DEV_BROADCAST_DEVICE_INTERFACE();
            IntPtr devBroadcastDeviceInterfacebuffer;

            Int32 size = 0;

            System.Guid guid = new Guid();

            size = Marshal.SizeOf(devBoardcastDeviceInterface);

            HidD_GetHidGuid(ref guid);

            devBoardcastDeviceInterface.dbcc_size       = size;
            devBoardcastDeviceInterface.dbcc_deviceType = DBT_DEVTYP_DEVICE_INTERFACE;
            devBoardcastDeviceInterface.dbcc_reserved   = 0;
            devBoardcastDeviceInterface.dbcc_classguid  = guid;

            devBroadcastDeviceInterfacebuffer = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(devBoardcastDeviceInterface, devBroadcastDeviceInterfacebuffer, true);

            m_deviceNotificationHandle = RegisterDeviceNotification
                                         (
                r_HANDLE,
                devBroadcastDeviceInterfacebuffer,
                DEVICE_NOTIFY_WINDOW_HANDLE
                                         );

            Marshal.FreeHGlobal(devBroadcastDeviceInterfacebuffer);
        }
Esempio n. 2
0
        public void RegisterHidEvent(
             IntPtr r_HANDLE
         )
        {
            DEV_BROADCAST_DEVICE_INTERFACE devBoardcastDeviceInterface = new DEV_BROADCAST_DEVICE_INTERFACE();
            IntPtr devBroadcastDeviceInterfacebuffer;

            Int32 size = 0;
            System.Guid guid = new Guid();

            size = Marshal.SizeOf(devBoardcastDeviceInterface);

             HidD_GetHidGuid( ref guid);

            devBoardcastDeviceInterface.dbcc_size = size;
            devBoardcastDeviceInterface.dbcc_deviceType = DBT_DEVTYP_DEVICE_INTERFACE;
            devBoardcastDeviceInterface.dbcc_reserved = 0;
            devBoardcastDeviceInterface.dbcc_classguid = guid;

            devBroadcastDeviceInterfacebuffer = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr( devBoardcastDeviceInterface, devBroadcastDeviceInterfacebuffer, true );

            m_deviceNotificationHandle = RegisterDeviceNotification
                                         (
                                              r_HANDLE,
                                              devBroadcastDeviceInterfacebuffer,
                                              DEVICE_NOTIFY_WINDOW_HANDLE
                                         );

            Marshal.FreeHGlobal(devBroadcastDeviceInterfacebuffer);
        }