/// /// 验证WinRar是否安装。 /// /// true:已安装,false:未安装 private static bool ExistsRar(out String winRarPath) { winRarPath = String.Empty; //通过Regedit(注册表)找到WinRar文件 var registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe"); if (registryKey == null) return false;//未安装 //registryKey = theReg;可以直接返回Registry对象供会面操作 winRarPath = registryKey.GetValue("").ToString();//这里为节约资源,直接返回路径,反正下面也没用到 registryKey.Close();//关闭注册表 return !String.IsNullOrEmpty(winRarPath); } //csharp/5821