Old 26th February 2008, 20:46   #1
csquared
Junior Member
 
Join Date: Aug 2007
Posts: 6
Text Box

I have searched the forums for this but have not found something that works. I have a custom page that has a text box in it, Field 4. I want to read from the user's registry and insert a value into this text box. The reading from the registry appears to be working but the writing to the text box appears not to be working. I have tried the following:

ReadRegStr $DatabaseServer HKLM "SOFTWARE\test" "TestServer"

!insertmacro MUI_INSTALLOPTIONS_WRITE "DatabaseLogin.ini" "Field 4" "State" $DatabaseServer

----

ReadRegStr $DatabaseServer HKLM "SOFTWARE\test" "TestServer"

!insertmacro MUI_INSTALLOPTIONS_WRITE "DatabaseLogin.ini" "Field 4" "Text" $DatabaseServer

---

ReadRegStr $DatabaseServer HKLM "SOFTWARE\test" "TestServer"

!insertmacro MUI_INSTALLOPTIONS_WRITE "DatabaseLogin.ini" "Field 4" "State" $DatabaseServer

----

WriteINIStr '$PLUGINSDIR\DatabaseLogin.ini' "Field 4" "State" $DatabaseServer


I think it may have to do with where I'm placing it I do not know for sure. I've tried before and after this section of code:

!insertmacro MUI_INSTALLOPTIONS_EXTRACT "DatabaseLogin.ini"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "DatabaseLogin.ini"

in my Form show area. Please let me know if you need more information or if you can help.
Thank you!
csquared is offline   Reply With Quote
Old 26th February 2008, 22:09   #2
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,366
are you writing this to the ini-file before displaying the page?
Yathosho is offline   Reply With Quote
Old 27th February 2008, 03:55   #3
csquared
Junior Member
 
Join Date: Aug 2007
Posts: 6
I don't know 100% what you mean. I have done it before and after I call the function for the page and before and after this line and it has made no difference. Can you maybe clarify more?

!insertmacro MUI_INSTALLOPTIONS_DISPLAY "DatabaseLogin.ini"
csquared is offline   Reply With Quote
Old 27th February 2008, 05:09   #4
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Just 3 steps:
1st extract the INI
2nd modify it
3rd display it

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 27th February 2008, 05:31   #5
csquared
Junior Member
 
Join Date: Aug 2007
Posts: 6
Right after the extract I tried setting the value and it still did not work. I have no clue what I'm doing wrong. When I go to the page that should have the value change it still says the default value. Here is what I tried:

!insertmacro MUI_INSTALLOPTIONS_EXTRACT "DatabaseLogin.ini"

!insertmacro MUI_INSTALLOPTIONS_WRITE "DatabaseLogin.ini" "Field 4" "State" "Hello"

WriteINIStr '$PLUGINSDIR\DatabaseLogin.ini' "Field 4" "State" "test"

WriteINIStr '$PLUGINSDIR\DatabaseLogin.ini' "Field 4" "Text" "test2"

None of the values were in the text box as I would have expected. Just 127.0.0.1 was in the text box which is the default value that I set when creating the text box on the page.

Thank you! Sorry I'm having such a hard time with this.
csquared is offline   Reply With Quote
Old 27th February 2008, 06:33   #6
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
code:
outfile test.exe
showinstdetails show

!include winmessages.nsh

Page license
Page custom CreateCustom
page Instfiles

Function CreateCustom
InitPluginsDir
WriteINIStr "$PLUGINSDIR\Cust.ini" "Settings" "NumFields" "1"
WriteINIStr "$PLUGINSDIR\Cust.ini" "Field 1" "Type" "Text"
WriteINIStr "$PLUGINSDIR\Cust.ini" "Field 1" "Top" "59"
WriteINIStr "$PLUGINSDIR\Cust.ini" "Field 1" "Bottom" "-59"
WriteINIStr "$PLUGINSDIR\Cust.ini" "Field 1" "Left" "20"
WriteINIStr "$PLUGINSDIR\Cust.ini" "Field 1" "Right" "-20"
WriteINIStr "$PLUGINSDIR\Cust.ini" "Field 1" "State" "Hello, I am a text field."

push $0
InstallOptions::InitDialog /NOUNLOAD "$PLUGINSDIR\Cust.ini"
ReadRegStr $R0 HKLM "SOFTWARE\NSIS" ""
messagebox mb_ok "$R0"
ReadINIStr $R1 "$PLUGINSDIR\Cust.ini" "Field 1" "hwnd"
SendMessage $R1 ${WM_SETTEXT} 0 "STR:$R0"

pop $0
InstallOptions::Show "$PLUGINSDIR\Cust.ini"
pop $0
pop $0
FunctionEnd


section

sectionend


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 27th February 2008, 14:00   #7
csquared
Junior Member
 
Join Date: Aug 2007
Posts: 6
In order for this to work, do I have to create the INI file in the fly like you did? I think my issue is that I have created the ini file in a separate file already with a GUI editor in Eclipse, and I'm calling and using that.
csquared is offline   Reply With Quote
Old 27th February 2008, 14:25   #8
csquared
Junior Member
 
Join Date: Aug 2007
Posts: 6
Here is what I have maybe this will help.

My DatabaseLogin.ini file
code:

[Settings]
NumFields=7

[Field 1]
Type=Label
Left=41
Top=49
Right=101
Bottom=58
Text=Database Server:

[Field 2]
Type=Label
Left=41
Top=66
Right=112
Bottom=75
Text=Database Username:

[Field 3]
Type=Label
Left=41
Top=84
Right=112
Bottom=94
Text=Database Password:

[Field 4]
Type=Text
Left=120
Top=46
Right=252
Bottom=59
State=127.0.0.1

[Field 5]
Type=Text
Left=120
Top=64
Right=252
Bottom=77
State=sa

[Field 7]
Type=Label
Left=41
Top=15
Right=228
Bottom=38
Text=Please enter your database connection information below.
[Field 6]
Type=Password
Left=120
Top=82
Right=252
Bottom=95



Installer Code - I kind of chopped it up a little so some basic stuff may be missing.
code:

ReserveFile "DatabaseLogin.ini"

!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

; The name of the installer
Name "Installer"

; The file to write
OutFile "setup.exe"

; The default installation directory
InstallDir "C:\Installer"

;Uninstall mode
!insertmacro UNATTENDED_UNINSTALL

; Pages
!insertmacro MUI_PAGE_WELCOME
Page custom SQLLoginInfoShow SQLLoginInfoLeave
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

;Page components

## Languages
!insertmacro MUI_LANGUAGE "English"

; Variables
var InstallSQL
var DatabaseServer
var DatabaseUsername
var DatabasePassword
var Upgrade

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

Function .onInit
Call CheckIISVersion
FunctionEnd

Function SQLLoginInfoShow
${if} $InstallSQL == 1
Abort
${Endif}

WriteINIStr '$PLUGINSDIR\DatabaseLogin.ini' "Field 4" "State" "blah"

!insertmacro MUI_HEADER_TEXT "Database Login Information" "Please enter your database login inforation below."
;ReserveFile "DatabaseLogin.ini"

!insertmacro MUI_INSTALLOPTIONS_EXTRACT "DatabaseLogin.ini"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "DatabaseLogin.ini"


FunctionEnd

Function SQLLoginInfoLeave
readinistr $DatabaseServer '$PLUGINSDIR\DatabaseLogin.ini' 'Field 4' 'State'
readinistr $DatabaseUsername '$PLUGINSDIR\DatabaseLogin.ini' 'Field 5' 'State'
readinistr $DatabasePassword '$PLUGINSDIR\DatabaseLogin.ini' 'Field 6' 'State'
;check to make sure they can login to the db provided
MSSQL_OLEDB::SQL_Logon /NOUNLOAD "$DatabaseServer" "$DatabaseUsername" "$DatabasePassword"
pop $0
${if} $0 == 1
;Error connecting to SQL Database
pop $0
MSSQL_OLEDB::SQL_GetError /NOUNLOAD
Pop $0
Pop $0
MessageBox MB_OK $0
Abort
${Endif}

FunctionEnd


csquared is offline   Reply With Quote
Old 27th February 2008, 15:01   #9
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Of course there's no need to create the INI on the fly, I did so just for convenience.
Taking a look at your code,
remove the line !insertmacro MUI_INSTALLOPTIONS_EXTRACT "DatabaseLogin.ini" and add it into function .onInit.

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 27th February 2008, 15:19   #10
csquared
Junior Member
 
Join Date: Aug 2007
Posts: 6
Awesome! that was it. Thank you and sorry I was difficult
csquared is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump