示例#1
0
 public IntPtr RegisterNotification(IntPtr handle)
 {
     this.handle = handle;
     NativeMethods.DEV_BROADCAST_DEVICEINTERFACE broadcastDeviceinterface = new NativeMethods.DEV_BROADCAST_DEVICEINTERFACE();
     broadcastDeviceinterface.dbcc_devicetype = 5;
     broadcastDeviceinterface.dbcc_size = Marshal.SizeOf((object)broadcastDeviceinterface);
     broadcastDeviceinterface.dbcc_reserved = 0;
     broadcastDeviceinterface.dbcc_classguid = this.USBClassID;
     IntPtr num1 = IntPtr.Zero;
     IntPtr num2 = Marshal.AllocHGlobal(Marshal.SizeOf((object)broadcastDeviceinterface));
     Marshal.StructureToPtr((object)broadcastDeviceinterface, num2, false);
     IntPtr num3 = IntPtr.Zero;
     return NativeMethods.RegisterDeviceNotification(handle, num2, 0);
 }
示例#2
0
        public IntPtr RegisterNotification(IntPtr handle)
        {
            this.handle = handle;
            NativeMethods.DEV_BROADCAST_DEVICEINTERFACE broadcastDeviceinterface = new NativeMethods.DEV_BROADCAST_DEVICEINTERFACE();
            broadcastDeviceinterface.dbcc_devicetype = 5;
            broadcastDeviceinterface.dbcc_size       = Marshal.SizeOf((object)broadcastDeviceinterface);
            broadcastDeviceinterface.dbcc_reserved   = 0;
            broadcastDeviceinterface.dbcc_classguid  = this.USBClassID;
            IntPtr num1 = IntPtr.Zero;
            IntPtr num2 = Marshal.AllocHGlobal(Marshal.SizeOf((object)broadcastDeviceinterface));

            Marshal.StructureToPtr((object)broadcastDeviceinterface, num2, false);
            IntPtr num3 = IntPtr.Zero;

            return(NativeMethods.RegisterDeviceNotification(handle, num2, 0));
        }