如果相关软件已经安装,我需要制作一个安装程序,该安装程序也可以作为修复/卸载程序。
我设法制作了一个自定义页面来检查程序是否存在并根据它显示按钮(注册表项的创建仅用于测试目的,应包含在安装过程中)。
例如,如果未安装程序,则会出现安装按钮。
这是执行此操作的代码:
Page Custom MyCustomPage
var button
var buttonRepair
var buttonUninstall
var dialog
Function MyCustomPage
ReadRegStr $R0 HKLM ${P_DIR_REGKEY} "Version"
${If} ${Errors}
Goto NotInstalled
${Else}
Goto Installed
${EndIf}
NotInstalled:
nsDialogs::Create 1018
;Pop $dialog
${NSD_CreateButton} 25% 25% 50% 50% "Install"
Pop $button
EnableWindow $button 1 # start out disabled
WriteRegStr HKLM ${P_DIR_REGKEY} "Version" ${P_VERSION}
WriteRegStr HKLM ${P_DIR_REGKEY} "" "$INSTDIR\asd.exe"
nsDialogs::Show
${NSD_OnClick} $button ManageInstall
Goto MyEnd
Installed:
nsDialogs::Create 1018
Pop $0
${NSD_CreateButton} 12% 12% 25% 25% "Repair"
Pop $buttonRepair
${NSD_CreateButton} 37% 12% 25% 25% "Uninstall"
Pop $buttonUninstall
EnableWindow $button 1 # start out disabled
EnableWindow $button2 1
${NSD_OnClick} $buttonRepair ManageRepair
${NSD_OnClick} $buttonUninstall ManageUninstall
nsDialogs::Show
Goto MyEnd
MyEnd:
Quit
FunctionEnd
Function ManageInstall
MessageBox MB_OK "Installation"
FunctionEnd
Function ManageRepair
MessageBox MB_OK "Repair"
FunctionEnd
Function ManageUninstall
MessageBox MB_OK "Uninstallation"
FunctionEnd
问题是它都是由函数管理的,我无法在其中声明新的页面宏,因此我无法继续通过部分进行正确安装。
我应该如何管理安装程序要采取的不同操作,以便能够像正常安装一样制作用户友好的页面?
我是否应该为每个操作使用自定义页面,因为这听起来有点挑剔和复杂?