- NSIS Discussion
- WriteIniStr to insert values on a custom page?
Archive: WriteIniStr to insert values on a custom page?
odyssey5
9th April 2009 15:09 UTC
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?
Red Wine
9th April 2009 15:19 UTC
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?
odyssey5
9th April 2009 15:37 UTC
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 :(
Red Wine
9th April 2009 15:47 UTC
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.
odyssey5
9th April 2009 16:35 UTC
I think this is the best example I can find, but I'm totally lost at all the addresses :(
I'm new to this...
odyssey5
9th April 2009 16:37 UTC
So I can't post links? Great...
h t t p://forums.winamp.com/showthread.php?s=&threadid=303378&highlight=SendMessage
Red Wine
9th April 2009 20:33 UTC
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
sprinleo
17th September 2009 07:54 UTC
does anybody know what's the difference between WriteINIStr and INSTALLOPTIONS_WRITE, how are they different from each other ?
thanks...
jpderuiter
17th September 2009 11:05 UTC
No difference, MUI_INSTALLOPTIONS_WRITE is just a macro using WriteINIStr:
http://forums.winamp.com/showthread.php?postid=1610834
sprinleo
17th September 2009 11:46 UTC
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"