Skip to content
⌘ NSIS Forum Archive

ReadReg Button

6 posts

didava#

ReadReg Button

sorry not working

1-ReadReg
2-if was
3-Enable & disable Button

outfile test.exe
!include MUI2.nsh
!include nsdialogs.nsh
page custom  nsDialogsPage
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function nsDialogsPage
    nsDialogs::Create /NOUNLOAD 1018
        Pop $0
    ${IfThen} $0 == error ${|} Abort ${|}
    ${NSD_CreateGroupBox} 0u 13u 85% 45% "If you dare click the button"
        Pop $R0
    ${NSD_CreateButton}  140 61u 20% 12u "Wmp11"
        Pop $R0
        ReadRegDWORD $R0 HKLM 'Software\Microsoft\Sof\Wmp11' Install
        EnableWindow $R0 0
    ${NSD_CreateButton}  140 41u 20% 12u "ExecYms9"
        Pop $R1
        ReadRegDWORD $R1 HKLM 'Software\Microsoft\Sof\Yms9' Install
        EnableWindow $R1 1
    ${NSD_OnClick} $R1 ExecYms9
    ${NSD_OnClick} $R1 ExecWmp11
    nsDialogs::Show
FunctionEnd
Function ExecYms9
    File /oname=$PLUGINSDIR\yms9.exe "prog\yms9.exe"
    ExecWait `$PLUGINSDIR\yms9.exe` $R9
FunctionEnd
Function ExecWmp11
    File /oname=$PLUGINSDIR\Wmp11.exe "prog\Wmp11.exe"
    ExecWait `$PLUGINSDIR\Wmp11.exe` $R9
FunctionEnd
section
sectionend 
thanks alot for your help
didava#
edit

1-ReadReg
2-if was install disable Button
3-(No install - Enable Button) & (installed - disable Button)

ReadRegDWORD $R1 HKLM 'Software\Microsoft\SofYms9' Install

ReadRegDWORD $R0 HKLM 'Software\Microsoft\SofWmp11' Install
didava#
    ${NSD_CreateButton}  140 61u 20% 12u "Wmp11"
        Pop $R0
        ReadRegDWORD $R0 HKLM 'SoftwareMicrosoftSofWmp11' Install
        ReadRegDWORD $R1 HKLM 'SoftwareMicrosoftSofWmp11' NoInstall
        EnableWindow $R0 0
        EnableWindow $R1 1
    ${NSD_CreateButton}  140 41u 20% 12u "ExecYms9"
        Pop $R1
        ReadRegDWORD $R2 HKLM 'SoftwareMicrosoftSofYms9' Install
        ReadRegDWORD $R3 HKLM 'SoftwareMicrosoftSofYms9' NoInstall
        EnableWindow $R1 0
        EnableWindow $R3 1 
didava#
hi! we want to make a program in which we have one button. when we run the program, we want the button to be in a state in which: if the registry value was 'install', the button becomes active, and if it was 'noinstall', the button becomes inactive. and also please take a look at the above script and see what is its problem. thanks in advance.
pospec#
Wmp11's button HWND is overwritten by reading registry dword into R0.
If you want to have one button enabled and other one disabled (or vice versa) then you should enable/disable the buttons after creating them and reading registries.