Archive: InstallOptions directory page w/ default value set at runtime


InstallOptions directory page w/ default value set at runtime
I've been mulling over this for a while and I can't find any details in docs or search. so...

I'm using InstallOptions to make a directory page using a DirRequest field.

In the ini file I can provide a State="D:\path" to provide a default in the field. However, I need the default value to be determined at runtime. I call a script function that returns the string I need, then I do a:

WriteINIStr "file.ini" "Field 1" "State" $0
FlushINI "file.ini"

However, the value in $0 never shows up as a default value when I test the install. Suspecting $0 is wrong, I do a MessageBox MB_OK $0, yet it shows that $0 contains the value I need.

Is this a bug? Is there something I'm doing wrong?


Please disregard. I just figured out the error.

For the archives, you cannot use WriteINIStr for InstallOptions ini files when using Modern UI. You must do the process:


!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "ioFile.ini"
Pop $0 # dlg hwnd
GetDlgItem $1 $0 1200 # get handle to first first item
SendMessage $1 ${WM_SETTEXT} "" "STR:Your new text" # you need STR:, don't remove it
!insertmacro MUI_INSTALLOPTIONS_SHOW


Then I also had an error in my ini file that prevented my code from working. Now, things are fine.

Of course you can use WriteINIStr, you just need to know where the file is. When you extract it using the MUI macros, it's in $PLUGINSDIR. You can use the full path or the MUI macro to write into INI files that are in $PLUGINSDIR, MUI_INSTALLOPTIONS_WRITE.