如何访问使用c#lang安装的驱动程序列表。 [英] how to access the list of drivers installed using c# lang.

查看:62
本文介绍了如何访问使用c#lang安装的驱动程序列表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这个并没有给出驱动程序列表。我试图在列表或数组中获取驱动程序列表。





I have tried this and its not giving the list of drivers. I am trying to get the driver list in a list or array.


ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PnPSignedDriver");

                foreach (ManagementObject obj in searcher.Get())

                {
                    string s;
                    s = string.IsNullOrEmpty(obj.GetPropertyValue("DeviceName").ToString()) ? string.Empty : obj.GetPropertyValue("DeviceName").ToString();
                    Debug.Print(s);
                }





请为我推荐一些不同的方法。



提前谢谢



Please suggest me some different methods.

Thanks in advance

推荐答案

您的代码中存在一个错误,调试器可能会找到该错误。试试我修改后的版本:

There is a bug in your code, which the debugger would have found for you. Try my modified version which works:
foreach (ManagementObject obj in searcher.Get())
{
    if (obj.GetPropertyValue("DeviceName") == null)
        continue;
    string s = obj.GetPropertyValue("DeviceName").ToString();
    if (!string.IsNullOrEmpty(s))
        Debug.Print(s);
}


这篇关于如何访问使用c#lang安装的驱动程序列表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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