列出所有系统调制解调器(List all System Modems)

编程入门 行业动态 更新时间:2024-10-18 05:55:31
列出所有系统调制解调器(List all System Modems)

托管代码中是否有一种方法可以列出系统上安装的调制解调器/电话设备? 如果.Net没办法,你能指点我吗?

Is there a way in managed code to list the Modem/Telephony devices installed on the system? If .Net does not have a way, could you point me in a direction?

最满意答案

WMI将包含Win32_POTSModem类中所需的所有信息。 在C#或.Net中,您可以使用System.Management命名空间来查询WMI。

在.Net中,您可以使用平台SDK中的MgmtclassGen.EXE生成表示WMI类的类对象。

命令行将是这样的:

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\mgmtclassgen.exe Win32_POTSModem /L CS /P c:\POTSModem\Win32_POTSModem.cs

然后你可以在你的代码中使用它:

using System; using System.Collections.Generic; using System.Management; using ROOT.CIMV2.Win32; public class MyClass { public static void Main() { foreach (POTSModem modem in POTSModem.GetInstances()) { Console.WriteLine(modem.Description); } } }

输出看起来像这样:

ThinkPad Modem - Internal Modem Speed: 56000

您还可以查看本文: CodeProject:如何:(几乎)通过C#在WMI中的所有内容 - 第3部分:硬件。 。 作者创建了一个类似于MgmtclassGen.exe的WMI对象的简单类包装器,但它们都是为你完成的。

WMI will contain all the information you need in the Win32_POTSModem class. In C# or .Net, you can utilize the System.Management namespace to query WMI.

Within .Net, you can use MgmtclassGen.EXE from the platform SDK to generate a class object representing the WMI class.

The command line would be like this:

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\mgmtclassgen.exe Win32_POTSModem /L CS /P c:\POTSModem\Win32_POTSModem.cs

and then you can use that in your code:

using System; using System.Collections.Generic; using System.Management; using ROOT.CIMV2.Win32; public class MyClass { public static void Main() { foreach (POTSModem modem in POTSModem.GetInstances()) { Console.WriteLine(modem.Description); } } }

Output looks like this:

ThinkPad Modem - Internal Modem Speed: 56000

You also might want to take a look at this article: CodeProject: How To: (Almost) Everything In WMI via C# - Part 3: Hardware.. The author has created a simple class wrapper around WMI objects similar to MgmtclassGen.exe, but its all done for you.

更多推荐

本文发布于:2023-08-03 13:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1390658.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:调制解调器   系统   List   System   Modems

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!