例如判断.Net4.0以后的版本可以使用这样去判断
private void Get45or451FromRegistry() { using (RegistryKey ndpKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\")) { if (ndpKey != null && ndpKey.GetValue("Release") != null) { versions += "\nv" + CheckFor45DotVersion((int)ndpKey.GetValue("Release")); } else { versions += "Version 4.5 or later is not detected."; } } } private string CheckFor45DotVersion(int releaseKey) { if (releaseKey == 394254 || releaseKey == 394271) { return "4.6.1"; } if (releaseKey >= 393295) { return "4.6 or later"; } if ((releaseKey >= 379893)) { return "4.5.2 or later"; } if ((releaseKey >= 378675)) { return "4.5.1 or later"; } if ((releaseKey >= 378389)) { return "4.5 or later"; } // This line should never execute. A non-null release key should mean // that 4.5 or later is installed. return "No 4.5 or later version detected"; }
那directX有没有同样的方法去判断注册表? 或判断系统文件夹有没有用相应的exe?
求详细代码,非常感谢!
解决方案
40
查看注册表 HKEY_LOCAL_MACHINE\Software\Microsoft\DirectX
读取 “Version” 的值
读取 “Version” 的值