将所有设置重置为其默认值
有没有办法将 Inno Setup 中的所有设置“重置”为默认值?
我想在我的设置中添加 重置选项
按钮,单击该按钮会将所有选项设置为相同的值,就好像用户从未更改任何内容,而只是单击下一步
,下一步
,安装
。
但请注意,这些值与编译时默认值
略有不同,例如AppDir
可以默认为DefaultDirName
或wizardForm .PrevAppDir
。所以我希望所有选项都默认为动态默认值
,对于AppDir
来说是:
if wizardForm.PrevAppDir <> '' then
result := wizardForm.PrevAppDir
else
result := '{#SetupSetting("DefaultDirName")}';
我希望你明白我想要完成的任务。如果应用程序已安装,则将所有选项设置为上次安装的值,如果应用程序未安装,则将它们设置为默认值。
我知道安装程序在启动时完成了所有这些操作,但我想添加一个按钮,它将用户所做的所有更改(例如在 wpSelectComponents
中)恢复为其安装启动默认值。我怎样才能做到这一点?
Is there any way to "reset" all setup settings in Inno Setup into their default values?
I want to add Reset options
button into my setup, and clicking that button would set all the options to the same value as if the user never changed anything, but was clicking just Next
, Next
, Install
.
But please note that those values ale slightly different than compile-time default values
, as for example AppDir
can default to DefaultDirName
or wizardForm.PrevAppDir
. So I want all the options to default to dynamic defaults
, which for AppDir
is:
if wizardForm.PrevAppDir <> '' then
result := wizardForm.PrevAppDir
else
result := '{#SetupSetting("DefaultDirName")}';
I hope you understand what I want to accomplish. If the application is already installed, then set all options to the last-installation values, if the app is not installed, then set them to default values.
I know the setup does all of this at it's startup, but I want to add a button, which would revert all the changes user made (eg. in wpSelectComponents
) to their setup-startup defaults. How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我在
[Code]
中解决了这个问题。所有信息都可以通过WizardForm
全局对象访问,因此当第一次显示配置页面时,您可以将这些值保存到变量中。然后,每当您需要重置配置时,只需再次通过WizardForm
恢复所有设置即可。我不会在这里粘贴整个代码,因为它有点长(172 LOC),但只有AppDir
部分:当您需要重置所有配置时,只需调用
RestoreDefaults
。当然,这不会恢复任何自定义向导选项/页面。但您可以自己轻松添加额外的存储/恢复代码。So I've solved this in
[Code]
. All the information is accessible throughWizardForm
global object, so when the configuration pages are shown for the first time, you save those values into your variables. Then, whenever you need to reset the configuration, you just restore all the settings throughWizardForm
again. I won't paste the whole code here, as it's kinda long (172 LOC), but there is just theAppDir
part:And when you need to reset all the configuration, just call
RestoreDefaults
. Of course, this won't restore any custom wizard options/pages. But you can add additional storing/restoring code easily yourself.