什么是检查Firefox安装最可靠的方法? [英] What is the most reliable way to check for firefox installation?

查看:191
本文介绍了什么是检查Firefox安装最可靠的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个与Firefox扩展捆绑在一起的软件。在我的安装脚本中,我想提示用户想要安装扩展的天气。但是为此,我需要:


  1. 一种判断是否安装firefox的方法

  2. 告诉哪个版本的firefox被安装的方法

我如何在InnoSetup或C#中做这两件事?我试着手动检查路径到默认的Firefox安装目录或检查注册表中的卸载记录。我认为这些方法是不可靠的。

解决方案

推荐的方法是检查 HKEY_LOCAL_MACHINE \\ \\ SOFTWARE \Mozilla \Mozilla Firefox 注册表项存在。每个安装的版本都会有一个子密钥。如果你是偏执的,你也可以检查值 HKEY_LOCAL_MACHINE \SOFTWARE\Mozilla\Mozilla Firefox\< version> \Main\PathToExe - 如果文件存在,那么Firefox是真正安装的,你没有看到一个陈旧的注册表键。

请注意,只有在安装程序被实际使用时才能检测Firefox安装。您可以随时手动安装Firefox,只需将安装可执行文件(使用7zip)解压到任何目录即可。夜间版本也可以作为普通的zip文件,更容易解压缩。这将工作得很好,但不会添加任何注册表项,这将允许您找到此安装。


I am making a software that comes bundled with a firefox extension. In my instalation script I want to prompt a user weather he wants to install the extension. But for that I need:

  1. A way to tell if firefox is installed or not
  2. A way to tell which version of firefox is installed

How would I do these two things in InnoSetup or C#? I tried manually checking the path to default firefox install dir or checking for uninstall records in registry. I think that these methods are not reliable at all.

解决方案

The recommended way is checking whether HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox registry key exists. There will be a subkey for each installed version. If you are paranoid, you can also check the value HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\<version>\Main\PathToExe - if that file exists then Firefox is really installed and you aren't looking at a stale registry key.

Note that you can only detect a Firefox installation only if the installer was actually used. You can always "install" Firefox manually, simply by unpacking the setup executable with 7zip - into any directory. Nightly builds are also available as regular zip files that are easier to unpack. This will work just fine but won't add any registry keys that will allow you to find this installation.

这篇关于什么是检查Firefox安装最可靠的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆