winform 通过驱动注册ID检测是否已安装驱动

 1  public bool IsRegistered()
 2         {
 3             string clsid = ConfigurationManager.AppSettings["clsid"];
 4             //参数检查
 5             Debug.Assert(!String.IsNullOrEmpty(clsid), "clsid 不应该为空");
 6             //设置返回值
 7             bool result = false;
 8             //检查方法,查找注册表是否存在指定的clsid
 9             string key = $@"CLSID\{{{clsid}}}";
10             RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(key);
11             if (regKey != null)
12             {
13                 result = true;
14             }
15             return result;
16         }
View Code

 

posted @ 2017-09-05 22:16  凌乱忘语  阅读(469)  评论(0编辑  收藏  举报