I made a custom page using NSIS and I created in it a CheckBox to set the homepage of Internet Explorer. I combined these codes which I collected from different sources
To create the CheckBox:
${NSD_CreateCheckbox} 8 80 10 10 "CheckBox1"
Pop $Custom_Page1_CheckBox1
GetFunctionAddress $0 OnCheckbox
nsDialogs::OnClick $Custom_Page1_CheckBox1 $0
ans this is the function I used to set the home page of Internet Explorer:
Function OnCheckbox
WriteRegStr HKCU "Software\Microsoft\Internet Explorer\Main" "Start Page" "http://www/homepage.com/"
FunctionEnd
The problem is there is no management of the selection which the user may choose.
How to solve this problem?
A OnClick handler is not the correct place to perform actions that change the users system.
You should check the state when the user is about to leave the page. If this custom page is before the InstFiles
page I would recommend that you just save the state in a variable and then perform the action in a section
at the same time as other install tasks.
!include nsDialogs.nsh
!include LogicLib.nsh
Page Custom MyPageCreate MyPageLeave
Page InstFiles
var OverrideIEHomeCheck
Function MyPageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateCheckbox} 8 80 50u 10u "Evil"
Pop $OverrideIEHomeCheck
nsDialogs::Show
FunctionEnd
Function MyPageLeave
${NSD_GetState} $OverrideIEHomeCheck $0
${If} $0 <> ${BST_UNCHECKED}
MessageBox mb_ok "Checked, do something now or remember the state"
${EndIf}
FunctionEnd