如何从特定端口名称获取设备信息? [英] How do I get device information from specific port names?

查看:230
本文介绍了如何从特定端口名称获取设备信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展一个与蓝牙通信相关的项目。

我从设备检索了所有COM端口名称COM12,COM23双SPPSOLONOID,现在我的问题是我可以获得与DeviceID,友好名称等设备相关的信息,但我需要获得上述实际名称设备如

Dual-SPP和SOLONOID。



我如何得到这个名字?请建议。

谢谢。



我尝试过:



I am now working on a project which related to bluetooth communication.
I retrieved all COM ports names "COM12" , "COM23" from devices "Dual-SPP" and "SOLONOID" , now my problem is I could get information related to device like "DeviceID", "Friendly name" , but i need to get the above actual names of device like
"Dual-SPP" and "SOLONOID".

How do i get this names? please suggest.
Thanks .

What I have tried:

ManagementObjectSearcher searcher =
                   new ManagementObjectSearcher("root\\CIMV2",
                   "SELECT * FROM Win32_PnPEntity");

               foreach (ManagementObject ManObj in searcher.Get())
               {
                   if (ManObj["Caption"].ToString().Contains("(COM"))
                   {
                       Console.WriteLine(ManObj["DeviceID"].ToString());
                       Console.WriteLine(ManObj["PNPDeviceID"].ToString());
                       Console.WriteLine(ManObj["Name"].ToString());
                       Console.WriteLine(ManObj["Caption"].ToString());
                       Console.WriteLine(ManObj["Description"].ToString());
                       Console.WriteLine(ManObj["ProviderType"].ToString());
                       Console.WriteLine(ManObj["Status"].ToString());
                   }
               }

推荐答案

是什么让你认为他们有一个像solonoid这样的实际名称可读?

友好名称是它的名称将Windows作为设备的人性友好描述,并且可能是您所希望的最好的。

Win32_SerialPort类(Windows) [ ^ ]其中包含description属性,但无论如何都有可能与友好名称相同(在事实上,它可能是ManagementObject返回的友好名称的来源。
What makes you think they have an "actual name" like "solonoid" which is machine readable?
The "friendly name" is the name it reports to Windows as a "human friendly" description of the device, and is probably about the best you can hope for.
There is Win32_SerialPort class (Windows)[^] which includes a "description" property, but the chances are that is the same as friendly name anyway (in fact it's probably teh source of the "friendly name" that ManagementObject returns).


这篇关于如何从特定端口名称获取设备信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆