コード例 #1
0
    private static string GetDevicePath(IntPtr hInfoSet, ref Win32Usb.DeviceInterfaceData oInterface)
    {
        uint nRequiredSize = 0;

        // Get the device interface details
        if (!Win32Usb.SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, IntPtr.Zero, 0, ref nRequiredSize, IntPtr.Zero))
        {
            Win32Usb.DeviceInterfaceDetailData oDetail = new Win32Usb.DeviceInterfaceDetailData();
            oDetail.Size = 5;   // hardcoded to 5! Sorry, but this works and trying more future proof versions by setting the size to the struct sizeof failed miserably. If you manage to sort it, mail me! Thx
            if (Win32Usb.SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, ref oDetail, nRequiredSize, ref nRequiredSize, IntPtr.Zero))
            {
                return(oDetail.DevicePath);
            }
        }
        return(null);
    }
コード例 #2
0
ファイル: NemoUsbHid.cs プロジェクト: minh3d/Fish
 private static string GetDevicePath(IntPtr hInfoSet, ref Win32Usb.DeviceInterfaceData oInterface)
 {
     uint nRequiredSize = 0;
     // Get the device interface details
     if (!Win32Usb.SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, IntPtr.Zero, 0, ref nRequiredSize, IntPtr.Zero))
     {
         Win32Usb.DeviceInterfaceDetailData oDetail = new Win32Usb.DeviceInterfaceDetailData();
         oDetail.Size = 5;	// hardcoded to 5! Sorry, but this works and trying more future proof versions by setting the size to the struct sizeof failed miserably. If you manage to sort it, mail me! Thx
         if (Win32Usb.SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, ref oDetail, nRequiredSize, ref nRequiredSize, IntPtr.Zero))
         {
             return oDetail.DevicePath;
         }
     }
     return null;
 }