Archive: WriteIniStr to insert values on a custom page?


WriteIniStr to insert values on a custom page?
I have created a custom page in MUI including a field that should (if it exists) read a value from registry and pre-fill out the field with this value. So far this is somewhat working:

ReadRegStr $1 HKLM "regpath..." ''
WriteIniStr 'custom.ini' 'Field 3' 'State' '$0'

However this does not just fill out the value in the custom page, but also alters my custom page ini-file.

I want this file to be unaltered since I use it for the setup - How do I avoid this?


Not quite sure what you mean when you say that you want the ini unaltered while you feed the ini field with the value however did you try SendMessage to feed the specific field when the custom page is initialized?


Well, I created the ini just to create the custom dialog, but I want to feed the text-fields with some values. It's not my intention to write any ini-files as the final values are supposed to be written in registry.

SendMessage may seem to do the job, but I don't understand the usage of it. Tried googling, with no help :(


Why googling when you have the NSIS manual, the included examples and firstly this forum?
SendMessage is built-in NSIS instruction and should be what you're looking for.
You'll probably find dozens examples here in forum.


I think this is the best example I can find, but I'm totally lost at all the addresses :(

I'm new to this...


So I can't post links? Great...

h t t p://forums.winamp.com/showthread.php?s=&threadid=303378&highlight=SendMessage


Okay, quick and dirty but you can get an idea:

outfile test.exe

!define my_custom_page '$PLUGINSDIR\custom.ini'

!include mui.nsh
!include winmessages.nsh

page custom cCreate
!insertmacro mui_page_instfiles

!insertmacro mui_language english

section -boo
;
sectionend

Function .onInit
InitPluginsDir
writeinistr '${my_custom_page}' 'settings' 'numfields' '1'
writeinistr '${my_custom_page}' "Field 1" "Type" "Text"
writeinistr '${my_custom_page}' "Field 1" "Flags" ""
writeinistr '${my_custom_page}' "Field 1" "State" "The Quick Brown Fox Jumps Over The Lazy Mad Dog"
writeinistr '${my_custom_page}' "Field 1" "Left" "10"
writeinistr '${my_custom_page}' "Field 1" "Right" "-10"
writeinistr '${my_custom_page}' "Field 1" "Top" "30"
writeinistr '${my_custom_page}' "Field 1" "Bottom" "42"
Functionend

function cCreate
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "custom.ini"

ReadINIStr $1 "${my_custom_page}" "Field 1" "hwnd"
SendMessage $1 ${EM_SETREADONLY} 1 0
SetCtlColors $1 0x000000 0xFFFFFF
ReadRegStr $R0 HKLM "Software\NSIS" ""
SendMessage $1 ${WM_SETTEXT} 0 'STR:$R0'

!insertmacro MUI_INSTALLOPTIONS_SHOW
functionend

does anybody know what's the difference between WriteINIStr and INSTALLOPTIONS_WRITE, how are they different from each other ?

thanks...


No difference, MUI_INSTALLOPTIONS_WRITE is just a macro using WriteINIStr:
http://forums.winamp.com/showthread.php?postid=1610834


ok, thanks for your quick reply, i am using this code display a custom page, but for some reason, this page is not being displayed at all, instead shows the subsequent page, thoughts ?

WriteINIStr "winst\DatabaseServer.ini" "Field 4" "State" "0"
!insertmacro INSTALLOPTIONS_DISPLAY "winst\DatabaseServer.ini"