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?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
WMI will contain all the information you need in the
Win32_POTSModem
class. In C# or .Net, you can utilize theSystem.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:
and then you can use that in your code:
Output looks like this:
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.
Just some thoughts for future generations.
@Christopher_G_Lewis provided very good solution. But before using WMI we have to check that
Windows Management Instrumentation
(WMI
, service nameWinmgmt
) is working (how to do it?). Of course, MS recommends don't touch this service, because it's part of system stuff, but people switch it off sometimes.Moreover, sometimes it may be helpful to check WMI version before using it.
If you want to get modems list which are connected at the moment, you can check out this solution. It works slowly, but shows all connected modems and excludes
Null modem cables
.