Exemplo n.º 1
0
        public static IntPtr RegisterDeviceInterface(IntPtr hwnd, DeviceNotifyType notificationType, Guid device)
        {
            DebugLogger.WriteLine("Registering {0}", device);

            DEV_BROADCAST_DEVICEINTERFACE devInt = new DEV_BROADCAST_DEVICEINTERFACE();

            devInt.dbcc_devicetype = dbch_devicetype.DBT_DEVTYP_DEVICEINTERFACE;
            devInt.dbcc_classguid  = device.ToByteArray();
            devInt.dbcc_size       = Marshal.SizeOf(devInt);


            IntPtr buffer = Marshal.AllocHGlobal(devInt.dbcc_size);

            try
            {
                Marshal.StructureToPtr(devInt, buffer, false);

                return(RegisterDeviceNotification(hwnd, buffer, notificationType)); //| DeviceNotifyType.DEVICE_NOTIFY_SERVICE_HANDLE
            }
            finally
            {
                Marshal.FreeHGlobal(buffer);
            }
        }
Exemplo n.º 2
0
 private static extern IntPtr RegisterDeviceNotification(IntPtr recipient, IntPtr notificationFilter, DeviceNotifyType flags);
Exemplo n.º 3
0
 internal static extern IntPtr RegisterPowerSettingNotification(IntPtr hRecipient, ref Guid PowerSettingGuid, DeviceNotifyType Flags);
Exemplo n.º 4
0
 internal static extern IntPtr RegisterPowerSettingNotification(IntPtr hRecipient, ref Guid PowerSettingGuid, DeviceNotifyType Flags);
        public static IntPtr RegisterDeviceInterface(IntPtr hwnd, DeviceNotifyType notificationType, Guid device)
        {
            DebugLogger.WriteLine("Registering {0}", device);

            DEV_BROADCAST_DEVICEINTERFACE devInt = new DEV_BROADCAST_DEVICEINTERFACE();
            devInt.dbcc_devicetype = dbch_devicetype.DBT_DEVTYP_DEVICEINTERFACE;
            devInt.dbcc_classguid = device.ToByteArray();
            devInt.dbcc_size = Marshal.SizeOf(devInt);


            IntPtr buffer = Marshal.AllocHGlobal(devInt.dbcc_size);
            try
            {
                Marshal.StructureToPtr(devInt, buffer, false);

                return RegisterDeviceNotification(hwnd, buffer, notificationType); //| DeviceNotifyType.DEVICE_NOTIFY_SERVICE_HANDLE
            }
            finally
            {
                Marshal.FreeHGlobal(buffer);
            }
        }
 private static extern IntPtr RegisterDeviceNotification(IntPtr recipient, IntPtr notificationFilter, DeviceNotifyType flags);