gpt4 book ai didi

.net - 如何在运行时检测XNA版本?

转载 作者:行者123 更新时间:2023-12-01 06:29:29 26 4
gpt4 key购买 nike

我有一个为.NET 2.0编写的启动程序/更新程序应用程序,需要检查用户是否已安装XNA 4.0。

如果不是,则要求用户安装它。

怎么做?

最佳答案

这是我为此编写的函数:

    public string CheckXNAFramework(out bool ok)
{
string output = "";

string baseKeyName = @"SOFTWARE\Microsoft\XNA\Game Studio";
Microsoft.Win32.RegistryKey installedFrameworkVersions = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(baseKeyName);

string[] versionNames = installedFrameworkVersions.GetSubKeyNames();

bool found = false;
foreach (string s in versionNames)
{
if (s == "v4.0")
{
found = true;
break;
}
}
if (found)
{
output += "Microsoft XNA Framework found successfully.\n";
ok = true;
}
else
{
output += "Correct version of the Microsoft XNA Framework not found. Please install version 4.0 or higher.\n";
ok = false;
}

return output;
}

关于.net - 如何在运行时检测XNA版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8301587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com