public static bool GetHIDDeviceAttributes(string devicePath, ref HIDD_ATTRIBUTES attribute) { if (string.IsNullOrWhiteSpace(devicePath)) { throw new ArgumentNullException(nameof(devicePath), "设备路径不能为空"); } IntPtr handle = Kernel32.Kernel32.CreateFile(devicePath, AccessRights.DEFAULT, ShareMode.FILE_SHARE_READ | ShareMode.FILE_SHARE_WRITE, IntPtr.Zero, CreationDisposition.OPEN_EXISTING, 0, IntPtr.Zero); bool result = HID.HidD_GetAttributes(new SafeFileHandle(handle, true), ref attribute); return(result); }
public static bool GetHIDDeviceAttributes(SafeFileHandle hidHandle, ref HIDD_ATTRIBUTES attribute) { bool result = HID.HidD_GetAttributes(hidHandle, ref attribute); return(result); }