public unsafe void RegisterUnregisterAllDevicesTest() { var callback = new CM_NOTIFY_CALLBACK(this.ProcessNotification); Assert.Equal(CONFIGRET.CR_SUCCESS, CM_Register_Notification( CM_NOTIFY_FILTER.AllDevices, null, callback, out SafeNotificationHandle context)); context.Dispose(); GC.KeepAlive(callback); }
public unsafe void RegisterErrorTest() { var callback = new CM_NOTIFY_CALLBACK(this.ProcessNotification); var filter = CM_NOTIFY_FILTER.Create(@"__INVALID__"); Assert.Equal(CONFIGRET.CR_FAILURE, CM_Register_Notification( &filter, null, callback, out SafeNotificationHandle context)); Assert.True(context.IsInvalid); }
public unsafe void RegisterUnregisterInstanceIdTest() { var callback = new CM_NOTIFY_CALLBACK(this.ProcessNotification); var filter = CM_NOTIFY_FILTER.Create(@"ROOT\BASICDISPLAY\0000"); Assert.Equal(CONFIGRET.CR_SUCCESS, CM_Register_Notification( &filter, null, callback, out SafeNotificationHandle context)); context.Dispose(); GC.KeepAlive(callback); }
public unsafe void RegisterUnregisterClassGuidTest() { var callback = new CM_NOTIFY_CALLBACK(this.ProcessNotification); // Register for USB events Assert.Equal(CONFIGRET.CR_SUCCESS, CM_Register_Notification( CM_NOTIFY_FILTER.Create(new Guid("A5DCBF10-6530-11D2-901F-00C04FB951ED")), null, callback, out SafeNotificationHandle context)); context.Dispose(); GC.KeepAlive(callback); }
public static unsafe extern CONFIGRET CM_Register_Notification( [Friendly(FriendlyFlags.In)] CM_NOTIFY_FILTER *pFilter, void *pContext, CM_NOTIFY_CALLBACK pCallback, out SafeNotificationHandle pNotifyContext);