简体   繁体   English

如何以编程方式确定Windows中是否安装了Mono 64位及其安装位置?

[英]How do I programmatically determine if and where Mono 64 bit is installed in Windows?

I found these registry settings 我发现了这些注册表设置

在此处输入图片说明

Assuming the user installed the Mono 64 bit MSI, can I in C# code read the registry and rely on 假设用户安装了Mono 64位MSI,我可以用C#代码读取注册表并依靠

  • 1 + 2 indicating that Mono 64 bit is installed 1 + 2表示已安装Mono 64位
  • 3 where the Mono lib folder is 3 Mono lib文件夹所在的位置
  • 4 where Mono config folder is and 4 Mono配置文件夹在哪里
  • 5 where the mono-2.0-sgen.dll is located. 5 mono-2.0-sgen.dll所在的位置。

I am asking because 我问是因为

  1. I did not find this documented on the Mono website (eg Mono FAQ: Technical , Install Mono on Windows , Mono Runtime Documentation , Mono Runtime Documentation ) 我没有在Mono网站上找到此文档(例如Mono FAQ:技术在Windows上安装MonoMono Runtime文档Mono Runtime文档
  2. Perhaps there is a better / alternative approach. 也许有更好的/替代方法。 (eg the GAC ... I'm not keen on the GAC but perhaps ...) (例如,GAC ...我并不热衷于GAC,但也许...)

(I assume that anything under Computer\\HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node would be 32 bit and would not indicate 64bit mono.) (我假设Computer \\ HKEY_LOCAL_MACHINE \\ SOFTWARE \\ WOW6432Node下的任何内容都是32位,并且不会表示64位单声道。)


Update I've asked on Mono-Github and here's their answer: https://github.com/mono/mono/issues/10535 更新我在Mono-Github上问过了,这是他们的答案: https : //github.com/mono/mono/issues/10535

.NET provides a series of classes for reading registry entry Here is an example of how to do that. .NET提供了一系列用于读取注册表项的类, 是如何执行操作的示例。 Another example is here 另一个例子在这里

In your case, the key location is number 1 from picture posted, the key is "Architecture" and it's "x64" and so on 在您的情况下,关键位置是发布的图片中的数字1,关键是“体系结构”和“ x64”,依此类推

Try that code from the above link and see if works. 从上面的链接尝试该代码,看看是否可行。 Some adaptation needs to be done. 需要进行一些调整。

If you get an error regarding administrative rights try to run Visual Studio as administrator. 如果遇到有关管理权限的错误,请尝试以管理员身份运行Visual Studio。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM