• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DeviceInterfaceData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DeviceInterfaceData的典型用法代码示例。如果您正苦于以下问题:C# DeviceInterfaceData类的具体用法?C# DeviceInterfaceData怎么用?C# DeviceInterfaceData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DeviceInterfaceData类属于命名空间,在下文中一共展示了DeviceInterfaceData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FindDevice

 public static HidDevice FindDevice(int nVid, int nPid, Type oType)
 {
     string strPath = string.Empty;
     string strSearch = string.Format("vid_{0:x4}&pid_{1:x4}", nVid, nPid);
     Guid gHid = HIDGuid;
     IntPtr hInfoSet = SetupDiGetClassDevs(ref gHid, null, IntPtr.Zero, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
     try
     {
         DeviceInterfaceData oInterface = new DeviceInterfaceData();
         oInterface.Size = Marshal.SizeOf(oInterface);
         int nIndex = 0;
         while (SetupDiEnumDeviceInterfaces(hInfoSet, 0, ref gHid, (uint)nIndex, ref oInterface))
         {
             string strDevicePath = GetDevicePath(hInfoSet, ref oInterface);
             if (strDevicePath.IndexOf(strSearch) >= 0)
             {
                 HidDevice oNewDevice = (HidDevice)Activator.CreateInstance(oType);
                 oNewDevice.Initialise(strDevicePath);
                 return oNewDevice;
             }
             nIndex++;
         }
     }
     catch(Exception ex)
     {
         throw HidDeviceException.GenerateError(ex.ToString());
     }
     finally
     {
         SetupDiDestroyDeviceInfoList(hInfoSet);
     }
     // No device found.
     return null;
 }
开发者ID:tylermenezes,项目名称:CSharp-MatrixBillAcceptor,代码行数:34,代码来源:HidDevice.cs


示例2: FindDevice

        /// <summary>
        /// Finds a device given its PID and VID
        /// </summary>
        /// <param name="nVid">Vendor id for device (VID)</param>
        /// <param name="nPid">Product id for device (PID)</param>
        /// <param name="oType">Type of device class to create</param>
        /// <returns>A new device class of the given type or null</returns>
        public static HIDDevice FindDevice(int nVid, int nPid, Type oType)
        {
            var searchPath = GetSearchPath(nVid, nPid); // first, build the path search string
            Guid gHid;
            HidD_GetHidGuid(out gHid);	// next, get the GUID from Windows that it uses to represent the HID USB interface
            var hInfoSet = SetupDiGetClassDevs(ref gHid, null, IntPtr.Zero, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);	// this gets a list of all HID devices currently connected to the computer (InfoSet)
            try
            {
                var oInterface = new DeviceInterfaceData();	// build up a device interface data block
                oInterface.Size = Marshal.SizeOf(oInterface);
                // Now iterate through the InfoSet memory block assigned within Windows in the call to SetupDiGetClassDevs
                // to get device details for each device connected
                for (var i = 0; SetupDiEnumDeviceInterfaces(hInfoSet, 0, ref gHid, (uint)i, ref oInterface); i++)	// this gets the device interface information for a device at index 'i' in the memory block
                {
                    var strDevicePath = GetDevicePath(hInfoSet, ref oInterface);	// get the device path (see helper method 'GetDevicePath')
                    if (strDevicePath.IndexOf(searchPath) < 0)
                        continue;

                    var oNewDevice = (HIDDevice)Activator.CreateInstance(oType);	// create an instance of the class for this device
                    oNewDevice.Initialise(strDevicePath);	// initialise it with the device path
                    return oNewDevice;	// and return it
                }
            }
            finally
            {
                // Before we go, we have to free up the InfoSet memory reserved by SetupDiGetClassDevs
                SetupDiDestroyDeviceInfoList(hInfoSet);
            }
            return null;	// oops, didn't find our device
        }
开发者ID:GaryWoodrow,项目名称:BuzzIO,代码行数:37,代码来源:HIDDevice.cs


示例3: Find

 public static string[] Find(int nVid, int nPid)
 {
     Guid guid;
     List<string> list = new List<string>();
     string str = string.Format("vid_{0:x4}&pid_{1:x4}", nVid, nPid);
     HidD_GetHidGuid(out guid);
     IntPtr lpDeviceInfoSet = SetupDiGetClassDevs(ref guid, null, IntPtr.Zero, 0x12);
     try
     {
         DeviceInterfaceData structure = new DeviceInterfaceData();
         structure.Size = Marshal.SizeOf(structure);
         for (int i = 0; SetupDiEnumDeviceInterfaces(lpDeviceInfoSet, 0, ref guid, (uint)i, ref structure); i++)
         {
             string devicePath = GetDevicePath(lpDeviceInfoSet, ref structure);
             if (devicePath.IndexOf(str) >= 0)
             {
                 list.Add(devicePath);
             }
         }
     }
     finally
     {
         SetupDiDestroyDeviceInfoList(lpDeviceInfoSet);
     }
     return list.ToArray();
 }
开发者ID:florianholzapfel,项目名称:LyncFellow,代码行数:26,代码来源:HIDDevices.cs


示例4: FindDevice

 /// <summary>
 /// Finds a device given its PID and VID
 /// </summary>
 /// <param name="VendorID">Vendor id for device (VID)</param>
 /// <param name="ProductID">Product id for device (PID)</param>
 /// <param name="oType">Type of device class to create</param>
 /// <returns>A new device class of the given type or null</returns>
 public static HIDDevice FindDevice(int VendorID, int ProductID, Type oType)
 {
     string strPath = string.Empty;
     string strSearch = string.Format("vid_{0:x4}&pid_{1:x4}", VendorID, ProductID); // first, build the path search string
     Guid gHid;
     HidD_GetHidGuid(out gHid);	// next, get the GUID from Windows that it uses to represent the HID USB interface
     IntPtr hInfoSet = SetupDiGetClassDevs(ref gHid, null, IntPtr.Zero, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);	// this gets a list of all HID devices currently connected to the computer (InfoSet)
     try
     {
         DeviceInterfaceData oInterface = new DeviceInterfaceData();	// build up a device interface data block
         oInterface.Size = Marshal.SizeOf(oInterface);
         // Now iterate through the InfoSet memory block assigned within Windows in the call to SetupDiGetClassDevs
         // to get device details for each device connected
         int nIndex = 0;
         while (SetupDiEnumDeviceInterfaces(hInfoSet, 0, ref gHid, (uint)nIndex, ref oInterface))	// this gets the device interface information for a device at index 'nIndex' in the memory block
         {
             string strDevicePath = GetDevicePath(hInfoSet, ref oInterface);	// get the device path (see helper method 'GetDevicePath')
             if (strDevicePath.IndexOf(strSearch) >= 0)	// do a string search, if we find the VID/PID string then we found our device!
             {
                 HIDDevice oNewDevice = (HIDDevice)Activator.CreateInstance(oType);	// create an instance of the class for this device
                 oNewDevice.Initialize(strDevicePath);	// initialise it with the device path
                 return oNewDevice;	// and return it
             }
             nIndex++;	// if we get here, we didn't find our device. So move on to the next one.
         }
     }
     finally
     {
         // Before we go, we have to free up the InfoSet memory reserved by SetupDiGetClassDevs
         SetupDiDestroyDeviceInfoList(hInfoSet);
     }
     return null;	// oops, didn't find our device
 }
开发者ID:CloneDeath,项目名称:VirtualHomeTheatre,代码行数:40,代码来源:HIDDevice.cs


示例5: SetupDiGetDeviceInterfaceDetail

        public static string SetupDiGetDeviceInterfaceDetail(
            SafeDeviceInfoSetHandle lpDeviceInfoSet,
            DeviceInterfaceData oInterfaceData,
            IntPtr lpDeviceInfoData)
        {
            var requiredSize = new NullableUInt32();

            // First call to get the size to allocate
            SetupDiGetDeviceInterfaceDetail(
                lpDeviceInfoSet,
                ref oInterfaceData,
                IntPtr.Zero,
                0,
                requiredSize,
                null);

            // As we passed an empty buffer we know that the function will fail, not need to check the result.
            var lastError = GetLastError();
            if (lastError != Win32ErrorCode.ERROR_INSUFFICIENT_BUFFER)
            {
                throw new Win32Exception(lastError);
            }

            var buffer = Marshal.AllocHGlobal((int)requiredSize.Value);

            try
            {
                Marshal.WriteInt32(buffer, DeviceInterfaceDetailDataSize.Value);

                // Second call to get the value
                var success = SetupDiGetDeviceInterfaceDetail(
                    lpDeviceInfoSet,
                    ref oInterfaceData,
                    buffer,
                    (uint)requiredSize,
                    null,
                    null);

                if (!success)
                {
                    Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    return null;
                }

                var strPtr = new IntPtr(buffer.ToInt64() + 4);
                return Marshal.PtrToStringAuto(strPtr);
            }
            finally
            {
                Marshal.FreeHGlobal(buffer);
            }
        }
开发者ID:vcsjones,项目名称:pinvoke,代码行数:52,代码来源:SetupApi.Helpers.cs


示例6: GetDevicePath

 private static string GetDevicePath(IntPtr hInfoSet, ref DeviceInterfaceData oInterface)
 {
     uint nRequiredSize = 0;
     if (!SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, IntPtr.Zero, 0, ref nRequiredSize, IntPtr.Zero))
     {
         DeviceInterfaceDetailData oDetailData = new DeviceInterfaceDetailData();
         oDetailData.Size = 5;
         if (SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, ref oDetailData, nRequiredSize, ref nRequiredSize, IntPtr.Zero))
         {
             return oDetailData.DevicePath;
         }
     }
     return null;
 }
开发者ID:florianholzapfel,项目名称:LyncFellow,代码行数:14,代码来源:HIDDevices.cs


示例7: FindDevice

        /// <summary>
        /// Finds a device given its PID and VID
        /// </summary>
        /// <param name="nVid">Vendor id for device (VID)</param>
        /// <param name="nPid">Product id for device (PID)</param>
        /// <param name="oType">Type of device class to create</param>
        /// <returns>A new device class of the given type or null</returns>
        public static USBDevice FindDevice(int nVid, int nPid, Type oType)
        {
            string strPath = string.Empty;
            string strSearch = string.Format("vid_{0:x4}&pid_{1:x4}", nVid, nPid); // first, build the path search string
            Guid gHid = new Guid("{0x28d78fad,0x5a12,0x11D1,{0xae,0x5b,0x00,0x00,0xf8,0x03,0xa8,0xc2}}");

            //HidD_GetHidGuid(out gHid);	// next, get the GUID from Windows that it uses to represent the HID USB interface
            IntPtr hInfoSet = SetupDiGetClassDevs(ref gHid, null, IntPtr.Zero, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);// this gets a list of all HID devices currently connected to the computer (InfoSet)
            try
            {
                DeviceInterfaceData oInterface = new DeviceInterfaceData();	// build up a device interface data block
                oInterface.Size = Marshal.SizeOf(oInterface);
                // Now iterate through the InfoSet memory block assigned within Windows in the call to SetupDiGetClassDevs
                // to get device details for each device connected
                int nIndex = 0;
                System.Console.WriteLine(gHid.ToString());
                System.Console.WriteLine(hInfoSet.ToString());
                Boolean Result = SetupDiEnumDeviceInterfaces(hInfoSet, 0, ref gHid, (uint)nIndex, ref oInterface);
                System.Console.WriteLine(Result.ToString());
                while (SetupDiEnumDeviceInterfaces(hInfoSet, 0, ref gHid, (uint)nIndex, ref oInterface))	// this gets the device interface information for a device at index 'nIndex' in the memory block
                    {
                        string strDevicePath = GetDevicePath(hInfoSet, ref oInterface);	// get the device path (see helper method 'GetDevicePath')
                        if (strDevicePath.IndexOf(strSearch) >= 0)	// do a string search, if we find the VID/PID string then we found our device!
                        {
                            USBDevice oNewDevice = (USBDevice)Activator.CreateInstance(oType);	// create an instance of the class for this device
                            //USBPRINT\VID_088c&PID_2030
                            oNewDevice.Initialise(strDevicePath);	// strDevicePath initialise it with the device path
                            return oNewDevice;	// and return it
                        }
                        nIndex++;	// if we get here, we didn't find our device. So move on to the next one.
                    }
                    System.Console.WriteLine(Marshal.GetLastWin32Error().ToString());
            }
            finally
            {
                // Before we go, we have to free up the InfoSet memory reserved by SetupDiGetClassDevs
                SetupDiDestroyDeviceInfoList(hInfoSet);
            }
            return null;	// oops, didn't find our device
        }
开发者ID:CubeFramework,项目名称:Platform,代码行数:47,代码来源:USBDevice.cs


示例8: SetupDiGetDeviceInterfaceDetail

 [DllImport("setupapi.dll", SetLastError = true)] protected static extern bool SetupDiGetDeviceInterfaceDetail(IntPtr lpDeviceInfoSet, ref DeviceInterfaceData oInterfaceData, ref DeviceInterfaceDetailData oDetailData, uint nDeviceInterfaceDetailDataSize, ref uint nRequiredSize, IntPtr lpDeviceInfoData);
开发者ID:TomRaven,项目名称:navxmxp,代码行数:1,代码来源:Win32USB.cs


示例9: SetupDiEnumDeviceInterfaces

		/// <summary>
		/// Gets the DeviceInterfaceData for a device from an InfoSet.
		/// </summary>
		/// <param name="lpDeviceInfoSet">InfoSet to access</param>
		/// <param name="nDeviceInfoData">Not used</param>
		/// <param name="gClass">Device class guid</param>
		/// <param name="nIndex">Index into InfoSet for device</param>
		/// <param name="oInterfaceData">DeviceInterfaceData to fill with data</param>
		/// <returns>True if successful, false if not (e.g. when index is passed end of InfoSet)</returns>
        [DllImport("setupapi.dll", SetLastError = true)] protected static extern bool SetupDiEnumDeviceInterfaces(IntPtr lpDeviceInfoSet, uint nDeviceInfoData, ref Guid gClass, uint nIndex, ref DeviceInterfaceData oInterfaceData);
开发者ID:TomRaven,项目名称:navxmxp,代码行数:10,代码来源:Win32USB.cs


示例10: SetupDiEnumDeviceInterfaces

 protected static extern bool SetupDiEnumDeviceInterfaces(IntPtr lpDeviceInfoSet, uint nDeviceInfoData, ref Guid gClass, uint nIndex, ref DeviceInterfaceData oInterfaceData);
开发者ID:CloneDeath,项目名称:VirtualHomeTheatre,代码行数:1,代码来源:Win32USB.cs


示例11: SetupDiEnumDeviceInterfaces

		/// <summary>
		/// Gets the DeviceInterfaceData for a device from an InfoSet.
		/// </summary>
		/// <param name="lpDeviceInfoSet">InfoSet to access</param>
		/// <param name="nDeviceInfoData">Not used</param>
		/// <param name="gClass">Device class guid</param>
		/// <param name="nIndex">Index into InfoSet for device</param>
		/// <param name="oInterfaceData">DeviceInterfaceData to fill with data</param>
		/// <returns>True if successful, false if not (e.g. when index is passed end of InfoSet)</returns>
        [DllImport("setupapi.dll", SetLastError = true)] internal static extern bool SetupDiEnumDeviceInterfaces(IntPtr lpDeviceInfoSet, IntPtr nDeviceInfoData, ref Guid gClass, Int32 nIndex, ref DeviceInterfaceData oInterfaceData);
开发者ID:teana0953,项目名称:WatchBP,代码行数:10,代码来源:Win32Usb.cs


示例12: GetDevicePath

		/// <summary>
		/// Helper method to return the device path given a DeviceInterfaceData structure and an InfoSet handle.
		/// Used in 'FindDevice' so check that method out to see how to get an InfoSet handle and a DeviceInterfaceData.
		/// </summary>
		/// <param name="hInfoSet">Handle to the InfoSet</param>
		/// <param name="oInterface">DeviceInterfaceData structure</param>
		/// <returns>The device path or null if there was some problem</returns>
		static string GetDevicePath(IntPtr hInfoSet, ref DeviceInterfaceData oInterface)
		{
			uint nRequiredSize = 0;
			// Get the device interface details
			if (!SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, IntPtr.Zero, 0, ref nRequiredSize, IntPtr.Zero))
			{
				DeviceInterfaceDetailData oDetail = new 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 (SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, ref oDetail, nRequiredSize, ref nRequiredSize, IntPtr.Zero))
				{
					return oDetail.DevicePath;
				}
			}
			return null;
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:22,代码来源:HIDDevice.cs


示例13: SetupDiGetDeviceInterfaceDetail

		public bool SetupDiGetDeviceInterfaceDetail(
            SafeDeviceInfoSetHandle deviceInfoSet,
            ref DeviceInterfaceData deviceInterfaceData,
            IntPtr deviceInterfaceDetailData,
            uint deviceInterfaceDetailDataSize,
            NullableUInt32 requiredSize,
            DeviceInfoData deviceInfoData)
			=> SetupDiGetDeviceInterfaceDetail(deviceInfoSet, ref deviceInterfaceData, deviceInterfaceDetailData, deviceInterfaceDetailDataSize, requiredSize, deviceInfoData);
开发者ID:ffMathy,项目名称:pinvoke-1,代码行数:8,代码来源:SetupApiMockable.cs


示例14: GetDevicePath

        private static string GetDevicePath(IntPtr hInfoSet, ref DeviceInterfaceData oInterface)
        {
            uint nRequiredSize = 0;
            if (!SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, IntPtr.Zero, 0, ref nRequiredSize, IntPtr.Zero))
            {
                DeviceInterfaceDetailData oDetail = new DeviceInterfaceDetailData();
                if (Marshal.SizeOf(typeof(IntPtr)) == 8)
                {
                    oDetail.Size = 8;
                }
                else
                {
                    oDetail.Size = 5;
                }

                if (SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, ref oDetail, nRequiredSize, ref nRequiredSize, IntPtr.Zero))
                {
                    return oDetail.DevicePath;
                }
            }
            return null;
        }
开发者ID:tylermenezes,项目名称:CSharp-MatrixBillAcceptor,代码行数:22,代码来源:HidDevice.cs


示例15: FindDevice

		/// <summary>
		/// Finds a device given its PID and VID
		/// </summary>
		/// <param name="nVid">Vendor id for device (VID)</param>
		/// <param name="nPid">Product id for device (PID)</param>
		/// <param name="oType">Type of device class to create</param>
		/// <returns>A new device class of the given type or null</returns>
		public static HIDDevice FindDevice(int nVid, int nPid, Type oType)
        {
            string strPath = string.Empty;
            string strSearch = @"#vid_" + nVid.ToString("x4") + "&pid_" + nPid.ToString("x4") + "#";
            //string strSearch = string.Format("VID_{0:X4}&PID_{1:X4}", nVid, nPid); // first, build the path search string
            Guid gHid = HIDGuid;
            HidD_GetHidGuid(ref gHid);	// next, get the GUID from Windows that it uses to represent the HID USB interface
            IntPtr hInfoSet = SetupDiGetClassDevs(ref gHid, IntPtr.Zero, IntPtr.Zero, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);   // this gets a list of all HID devices currently connected to the computer (InfoSet)
            try
            {
                var oInterface = new DeviceInterfaceData();	// build up a device interface data block
                oInterface.Size = Marshal.SizeOf(oInterface);
                //oInterface.Size = (IntPtr.Size == 4) ? (4 + Marshal.SystemDefaultCharSize) : 8;
                // Now iterate through the InfoSet memory block assigned within Windows in the call to SetupDiGetClassDevs
                // to get device details for each device connected
                int nIndex = 0;
                while (SetupDiEnumDeviceInterfaces(hInfoSet, IntPtr.Zero, ref gHid, nIndex, ref oInterface))	// this gets the device interface information for a device at index 'nIndex' in the memory block
                {
                    string strDevicePath = GetDevicePath(hInfoSet, ref oInterface);	// get the device path (see helper method 'GetDevicePath')
                    if (strDevicePath.IndexOf(strSearch) >= 0)	// do a string search, if we find the VID/PID string then we found our device!
                    {
                        HIDDevice oNewDevice = (HIDDevice)Activator.CreateInstance(oType);	// create an instance of the class for this device
                        oNewDevice.Initialise(strDevicePath);	// initialise it with the device path
                        return oNewDevice;	// and return it
                    }
                    nIndex++;	// if we get here, we didn't find our device. So move on to the next one.
                }
            }
            catch(Exception ex)
            {
                throw HIDDeviceException.GenerateError(ex.ToString());
                //Console.WriteLine(ex.ToString());
            }
            finally
            {
				// Before we go, we have to free up the InfoSet memory reserved by SetupDiGetClassDevs
                SetupDiDestroyDeviceInfoList(hInfoSet);
            }
            return null;	// oops, didn't find our device
        }
开发者ID:teana0953,项目名称:WatchBP,代码行数:47,代码来源:HIDDevice.cs


示例16: GetDevicePath

		/// <summary>
		/// Helper method to return the device path given a DeviceInterfaceData structure and an InfoSet handle.
		/// Used in 'FindDevice' so check that method out to see how to get an InfoSet handle and a DeviceInterfaceData.
		/// </summary>
		/// <param name="hInfoSet">Handle to the InfoSet</param>
		/// <param name="oInterface">DeviceInterfaceData structure</param>
		/// <returns>The device path or null if there was some problem</returns>
		private static string GetDevicePath(IntPtr hInfoSet, ref DeviceInterfaceData oInterface)
		{
			Int32 nRequiredSize = 0;
            IntPtr detailDataBuffer = IntPtr.Zero;
            
			// Get the device interface details
			if (!SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface, IntPtr.Zero, 0, ref nRequiredSize, IntPtr.Zero))
			{
                //DeviceInterfaceDetailData oDetail = new DeviceInterfaceDetailData();
                //oDetail.Size = (IntPtr.Size == 4) ? (4 + Marshal.SystemDefaultCharSize) : 8;
                detailDataBuffer = Marshal.AllocHGlobal(nRequiredSize);
                Marshal.WriteInt32(detailDataBuffer,(IntPtr.Size == 4)?(4+Marshal.SystemDefaultCharSize):8);

                //DeviceInterfaceDetailData oDetail = new 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 (SetupDiGetDeviceInterfaceDetail(hInfoSet, ref oInterface,detailDataBuffer , nRequiredSize, ref nRequiredSize, IntPtr.Zero))
				{
                    String devicePathName = "";
                    var pDevicePathName = new IntPtr(detailDataBuffer.ToInt64()+4);
                    devicePathName = Marshal.PtrToStringAuto(pDevicePathName);
                    Marshal.FreeHGlobal(detailDataBuffer);
                    return devicePathName;
                }
			}
			return null;
		}
开发者ID:teana0953,项目名称:WatchBP,代码行数:33,代码来源:HIDDevice.cs


示例17: GetDeviceFilename

        private String GetDeviceFilename(int vid, int pid)
        {
            string devname = string.Format("vid_{0:x4}&pid_{1:x4}", vid, pid);
            string filename = null;

            Guid gHid;
            HidD_GetHidGuid(out gHid);

            IntPtr hInfoSet = SetupDiGetClassDevs(ref gHid, null, IntPtr.Zero, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);

                DeviceInterfaceData oInterface = new DeviceInterfaceData();
                oInterface.Size = Marshal.SizeOf(oInterface);
            int nIndex = 0;
            while (SetupDiEnumDeviceInterfaces(hInfoSet, 0, ref gHid, (uint)nIndex, ref oInterface)) {
            string strDevicePath = GetDevicePath(hInfoSet, ref oInterface);
            System.Console.WriteLine(strDevicePath);
            if (strDevicePath.IndexOf(devname) >= 0){
                filename = strDevicePath;
                break;
            }
            nIndex++;
            }

                SetupDiDestroyDeviceInfoList(hInfoSet);

            return filename;
        }
开发者ID:suchfunsuchfun,项目名称:IS4C,代码行数:27,代码来源:USB-Win32.cs


示例18: SetupDiEnumDeviceInterfaces

		public bool SetupDiEnumDeviceInterfaces(
            SafeDeviceInfoSetHandle deviceInfoSet,
            DeviceInfoData deviceInfoData,
            ref Guid interfaceClassGuid,
            uint memberIndex,
            ref DeviceInterfaceData deviceInterfaceData)
			=> SetupDiEnumDeviceInterfaces(deviceInfoSet, deviceInfoData, ref interfaceClassGuid, memberIndex, ref deviceInterfaceData);
开发者ID:ffMathy,项目名称:pinvoke-1,代码行数:7,代码来源:SetupApiMockable.cs


示例19: SetupDiGetDeviceInterfaceDetail

 public static extern bool SetupDiGetDeviceInterfaceDetail(
   IntPtr handle,
   ref DeviceInterfaceData deviceInterfaceData,
   IntPtr unused1,
   int unused2,
   ref uint requiredSize,
   IntPtr unused3);
开发者ID:Azzuro,项目名称:IR-Server-Suite,代码行数:7,代码来源:Win32.cs


示例20: SetupDiGetDeviceInterfaceDetail

 public static extern bool SetupDiGetDeviceInterfaceDetail(
     IntPtr lpDeviceInfoSet,
     ref DeviceInterfaceData oInterfaceData,
     ref DeviceInterfaceDetailData oDetailData,  //We have the size -> send struct
     uint nDeviceInterfaceDetailDataSize,
     ref uint nRequiredSize,
     ref DevinfoData deviceInfoData);
开发者ID:romanbdev,项目名称:quickroute-gps,代码行数:7,代码来源:APIs.cs



注:本文中的DeviceInterfaceData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DeviceMode类代码示例发布时间:2022-05-24
下一篇:
C# DeviceInstallationCallback类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap