列出所有系统调制解调器 [英] List all System Modems

查看:75
本文介绍了列出所有系统调制解调器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

托管代码中是否有办法列出系统上安装的调制解调器/电话设备?如果.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.

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.

在.Net内,您可以使用 MgmtclassGen.EXE 从平台SDK生成代表WMI类的类对象.

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

命令行如下:

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);
    }
  }
}

输出看起来像这样:

ThinkPad Modem - Internal Modem
        Speed: 56000

您可能还想看一下这篇文章: CodeProject:操作方法:(几乎)通过C#在WMI中的所有内容-第3部分:硬件..作者围绕WMI对象创建了一个简单的类包装器,类似于MgmtclassGen.exe,但这一切都为您完成了.

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.

这篇关于列出所有系统调制解调器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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