在注册表中找到我安装的应用程序的路径 [英] find the path of my application installed in registry

查看:895
本文介绍了在注册表中找到我安装的应用程序的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用innosetup安装我的程序java,安装程序将生成密钥运行. 我想获取安装路径

Im using the innosetup to install my program java, the installer will generated the key run. I want to get the path of installation

innosetup行:

Line of innosetup:

Root: HKLM; 
Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; 
ValueType: string; 
ValueName: "Mi_Programak"; 
ValueData: "{app}\esperoo.exe";"

该类将调用到file,但是我需要安装路径,如何在注册表中找到应用程序名称的安装路径?

The class will called to file but I need the path of installation, how I get the path of installation finding in the registry with the name of my application?

推荐答案

我不知道安装的程序文件夹是否有内置的注册表项,但是您始终可以创建自己的注册表项.您可以让安装程序脚本在安装过程中使用{app}作为注册表值的占位符来创建注册表项.

I don't know if there is a built-in registry key for the installed program folder, but you can always create your own. You have the installer script create the registry key during installation, using {app} as the placeholder for the registry value.

从Java读取Windows注册表中的任意键都是很棘手的事情,但是要保持标准的JDK类和文档功能,最好使用标准的Preferences接口.系统根目录下的首选项将作为键放置在HKLM \ Software \ JavaSoft \ Prefs \下.请记住,大写字母有些奇怪-每个大写字母都以斜杠作为前缀,因此请保持键名的小写.例如installdir而不是InstallDir.

Reading from any arbitrary key in the Windows registry from Java can be done with some trickery, but to keep to standard JDK classes and documented features, it's best to use the standard Preferences interface. Preferences under the system root get placed as keys under HKLM\Software\JavaSoft\Prefs\. Bear in mind there is some strangeness with upper-case letters - each uppercase letter is prefixed with a slash, so keep the name of the key lowercase. e.g. installdir rather than InstallDir.

摘要:要找到安装目录,请在Software \ Java \ Prefs下将注册表项添加到安装程序脚本,然后您可以使用

In summary: to find the installation directory, add a registry key under Software\Java\Prefs to the installer script and you can use the system root of java.util.Preferences to retrieve the value at runtime.

这篇关于在注册表中找到我安装的应用程序的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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