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);
internal static extern IntPtr RegisterPowerSettingNotification(IntPtr hRecipient, ref Guid PowerSettingGuid, DeviceNotifyType Flags);
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);