!include 'MUI2.nsh'
Var /GLOBAL Var_INSTDIR
!define MUI_DIRECTORYPAGE_VARIABLE $Var_INSTDIR
!insertmacro MUI_PAGE_DIRECTORY
Function .onInit
StrCpy '$Var_INSTDIR' '$PROGRAMFILES32'
FunctionEnd
Function .onVerifyInstDir
FindWindow $R2 "#32770" "" $HWNDPARENT
GetDlgItem $R3 $R2 1019
SendMessage $R3 ${WM_SETTEXT} 0 "STR:$Var_INSTDIR\InsertMyNameProgram"
FunctionEnd
Section ABC
SectionEnd
It not SETTEXT for the textbox directory after user choose a folder by click OK on the "DialogBrowseFolder".
Can not SETTEXT for the textbox directory after user choose a folder
5 posts
You can see the path changing when you click on folders in the browse dialog, but as soon as ok is clicked, it just puts a backslash on it (because the directory is not valid). The whole point of .onverifyinstdir is to check for an existing folder, and your code always fails because the folder does not exist yet.
It's probably better to just choose the root directory (ie $programfiles32), and append your subdirectories to the path later and create the directories in a section.
It's probably better to just choose the root directory (ie $programfiles32), and append your subdirectories to the path later and create the directories in a section.
Yes, Is there a way to automatically add "MyNameProgram" to the path which users selected.
For example, the user selects D:\Software, it automatically add the string MyNameProgram in the end to become D:\Software\MyNameProgram
For example, the user selects D:\Software, it automatically add the string MyNameProgram in the end to become D:\Software\MyNameProgram
Why are you not using InstallDir?
Yes, I need check my path in registry
!include 'MUI2.nsh'
!define FullName 'MyProgramFullName'
!define InstDirDefault '$PROGRAMFILES32\${FullName}'
Var /GLOBAL Var_FINS
Var /GLOBAL Var_INSTDIR
!define MUI_DIRECTORYPAGE_VARIABLE $Var_INSTDIR
!insertmacro MUI_PAGE_DIRECTORY
Function .onInit
ReadRegStr $Var_FINS HKLM 'Software\${FullName}' 'PathInstall'
${If} '$Var_FINS' != ''
StrCpy '$Var_INSTDIR' '$Var_FINS'
${Else}
StrCpy '$Var_INSTDIR' '${InstDirDefault}'
${EndIf}
FunctionEnd
Function .onVerifyInstDir
FindWindow $R2 "#32770" "" $HWNDPARENT
GetDlgItem $R3 $R2 1019
SendMessage $R3 ${WM_SETTEXT} 0 "STR:$Var_INSTDIR\${FullName}"
FunctionEnd
Section ABC
SectionEnd
!include 'MUI2.nsh'
!define FullName 'MyProgramFullName'
!define InstDirDefault '$PROGRAMFILES32\${FullName}'
Var /GLOBAL Var_FINS
Var /GLOBAL Var_INSTDIR
!define MUI_DIRECTORYPAGE_VARIABLE $Var_INSTDIR
!insertmacro MUI_PAGE_DIRECTORY
Function .onInit
ReadRegStr $Var_FINS HKLM 'Software\${FullName}' 'PathInstall'
${If} '$Var_FINS' != ''
StrCpy '$Var_INSTDIR' '$Var_FINS'
${Else}
StrCpy '$Var_INSTDIR' '${InstDirDefault}'
${EndIf}
FunctionEnd
Function .onVerifyInstDir
FindWindow $R2 "#32770" "" $HWNDPARENT
GetDlgItem $R3 $R2 1019
SendMessage $R3 ${WM_SETTEXT} 0 "STR:$Var_INSTDIR\${FullName}"
FunctionEnd
Section ABC
SectionEnd