1. <small id='ReCXR'></small><noframes id='ReCXR'>

      2. <legend id='ReCXR'><style id='ReCXR'><dir id='ReCXR'><q id='ReCXR'></q></dir></style></legend><tfoot id='ReCXR'></tfoot>
        • <bdo id='ReCXR'></bdo><ul id='ReCXR'></ul>

        <i id='ReCXR'><tr id='ReCXR'><dt id='ReCXR'><q id='ReCXR'><span id='ReCXR'><b id='ReCXR'><form id='ReCXR'><ins id='ReCXR'></ins><ul id='ReCXR'></ul><sub id='ReCXR'></sub></form><legend id='ReCXR'></legend><bdo id='ReCXR'><pre id='ReCXR'><center id='ReCXR'></center></pre></bdo></b><th id='ReCXR'></th></span></q></dt></tr></i><div id='ReCXR'><tfoot id='ReCXR'></tfoot><dl id='ReCXR'><fieldset id='ReCXR'></fieldset></dl></div>

        在 Windows 7 下从 .NET 应用程序中查找 USB 串行端口

        时间:2023-11-10

        <small id='z5QTw'></small><noframes id='z5QTw'>

            <bdo id='z5QTw'></bdo><ul id='z5QTw'></ul>

              <tfoot id='z5QTw'></tfoot>

              <legend id='z5QTw'><style id='z5QTw'><dir id='z5QTw'><q id='z5QTw'></q></dir></style></legend>
              <i id='z5QTw'><tr id='z5QTw'><dt id='z5QTw'><q id='z5QTw'><span id='z5QTw'><b id='z5QTw'><form id='z5QTw'><ins id='z5QTw'></ins><ul id='z5QTw'></ul><sub id='z5QTw'></sub></form><legend id='z5QTw'></legend><bdo id='z5QTw'><pre id='z5QTw'><center id='z5QTw'></center></pre></bdo></b><th id='z5QTw'></th></span></q></dt></tr></i><div id='z5QTw'><tfoot id='z5QTw'></tfoot><dl id='z5QTw'><fieldset id='z5QTw'></fieldset></dl></div>

                  <tbody id='z5QTw'></tbody>
                  本文介绍了在 Windows 7 下从 .NET 应用程序中查找 USB 串行端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个应用程序可以查找具有自定义 USB 描述符的特定 FTDI 串行端口.我当前的代码使用 Code Project 中的示例,它搜索MSSerial_PortName rootWMI 下的 WMI 表,并从 rootCIMV2WIN32_PnPEntity 中提取额外的 USB 信息.

                  I have an application that looks for a specific FTDI serial port with customised USB descriptors. My current code uses the example from Code Project, which searches the MSSerial_PortName WMI table under rootWMI, and pulls out extra USB information from rootCIMV2WIN32_PnPEntity.

                  这在 XP 下运行良好,但应用程序也必须在 Windows 7 上的标准用户下运行.在这种环境下,rootWMI 的访问会导致访问被拒绝"ManagementException.

                  This worked well under XP, but the application must also run under a standard user onWindows 7. In this environment access of rootWMI results in an "Access Denied" ManagementException.

                  在以标准用户身份运行时,任何人都可以建议一种将串行端口的 DOS 设备名称与 USB 信息交叉引用的方法吗?到目前为止,我查看了 rootCIMV2WIN32_SerialPort* 表,但它们只包含主板端口.我也考虑过使用 SetupAPI,但我还没有找到一个完整且有效的 PInvoke 模板.

                  Can anybody suggest a way to cross reference the DOS device name of a serial port to the USB information, while running as a standard user? So far I've looked at the rootCIMV2WIN32_SerialPort* tables, but they only contain motherboard ports. I've also considered using SetupAPI, but I haven't found a complete and working PInvoke template for this.

                  推荐答案

                  我发现了一个适合我们案例的答案,虽然不是一个通用的答案.我们的 USB 转换器都是 FTDI,FTDI 提供了一个 DLL 来处理这个.我使用 DLL 的代码如下:

                  I've discovered an answer suitable for our case, though not a generic one. Our USB converters are all FTDI, and FTDI provide a DLL that handles this. My code using the DLL is below:

                  UInt32 count = 0;
                  FTDI.FT_STATUS status = ftdi.GetNumberOfDevices(ref count);
                  if (status != FTDI.FT_STATUS.FT_OK)
                  {
                      log.Warn("Unable to access FTDI");
                      return ports;
                  }
                  FTDI.FT_DEVICE_INFO_NODE[] list = new FTDI.FT_DEVICE_INFO_NODE[count];
                  status = ftdi.GetDeviceList(list);
                  if (status != FTDI.FT_STATUS.FT_OK)
                  {
                      log.Warn("Unable to access FTDI");
                      return ports;
                  }
                  foreach (FTDI.FT_DEVICE_INFO_NODE node in list)
                  {
                      if ((status = ftdi.OpenByLocation(node.LocId)) == FTDI.FT_STATUS.FT_OK)
                      {
                          try
                          {
                              string comport;
                              ftdi.GetCOMPort(out comport);
                              ports.Add(new Port(comport, node.Description, node.SerialNumber));
                          }
                          finally
                          {
                              ftdi.Close();
                          }
                      }
                  }
                  

                  这篇关于在 Windows 7 下从 .NET 应用程序中查找 USB 串行端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    <bdo id='UhRM2'></bdo><ul id='UhRM2'></ul>
                  • <legend id='UhRM2'><style id='UhRM2'><dir id='UhRM2'><q id='UhRM2'></q></dir></style></legend>
                    <tfoot id='UhRM2'></tfoot>
                  • <small id='UhRM2'></small><noframes id='UhRM2'>

                          <tbody id='UhRM2'></tbody>
                        <i id='UhRM2'><tr id='UhRM2'><dt id='UhRM2'><q id='UhRM2'><span id='UhRM2'><b id='UhRM2'><form id='UhRM2'><ins id='UhRM2'></ins><ul id='UhRM2'></ul><sub id='UhRM2'></sub></form><legend id='UhRM2'></legend><bdo id='UhRM2'><pre id='UhRM2'><center id='UhRM2'></center></pre></bdo></b><th id='UhRM2'></th></span></q></dt></tr></i><div id='UhRM2'><tfoot id='UhRM2'></tfoot><dl id='UhRM2'><fieldset id='UhRM2'></fieldset></dl></div>