Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
    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);
    }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
 public static unsafe extern CONFIGRET CM_Register_Notification(
     [Friendly(FriendlyFlags.In)] CM_NOTIFY_FILTER *pFilter,
     void *pContext,
     CM_NOTIFY_CALLBACK pCallback,
     out SafeNotificationHandle pNotifyContext);