1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Runtime.InteropServices;
- namespace NS_SoftKey_Win
- {
- /// <summary>
- /// Class1 µÄժҪ˵Ã÷¡£
- /// </summary>
- public class Win32
- {
- public const int WM_DEVICECHANGE = 0x0219;
- public const int DBT_DEVICEARRIVAL = 0x8000, // systemdetected a new device
- DBT_DEVICEREMOVECOMPLETE = 0x8004; // device is gone
- public const int DEVICE_NOTIFY_WINDOW_HANDLE = 0,
- DEVICE_NOTIFY_SERVICE_HANDLE = 1;
- public const int DBT_DEVTYP_DEVICEINTERFACE = 0x00000005; // deviceinterface class
- public static Guid GUID_DEVINTERFACE_USB_DEVICE = new
- Guid("4D1E55B2-F16F-11CF-88CB-001111000030");
- [StructLayout(LayoutKind.Sequential)] public class DEV_BROADCAST_HDR
- {
- public int dbcc_size;
- public int dbcc_devicetype;
- public int dbcc_reserved;
- }
- [StructLayout(LayoutKind.Sequential)] public class
- DEV_BROADCAST_DEVICEINTERFACE
- {
- public int dbcc_size;
- public int dbcc_devicetype;
- public int dbcc_reserved;
- public Guid dbcc_classguid;
- public short dbcc_name;
- }
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
- public class DEV_BROADCAST_DEVICEINTERFACE1
- {
- public int dbcc_size;
- public int dbcc_devicetype;
- public int dbcc_reserved;
- [MarshalAs(UnmanagedType.ByValArray, ArraySubType=UnmanagedType.U1,
- SizeConst=16)] public byte [] dbcc_classguid;
- [MarshalAs(UnmanagedType.ByValArray, SizeConst=128)] public char []
- dbcc_name;
- }
- [DllImport("user32.dll", SetLastError=true)] public static extern
- IntPtr RegisterDeviceNotification( IntPtr hRecipient, IntPtr
- NotificationFilter, Int32 Flags);
- [DllImport("kernel32.dll")] public static extern int GetLastError();
- }
- }
|