1 public bool IsRegistered() 2 { 3 string clsid = ConfigurationManager.AppSettings["clsid"]; 4 //參數檢查 5 Debug.Assert(!String.IsNullOrEmpty(clsid), "cl ...
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