Archive: Read Input & Insert to Registry


Read Input & Insert to Registry
Hi all,

I'm really trying to wrap my head around NSIS, but I am having a difficult time with it.

I have one thing I need the installer to do:

a) Check the registry to see if an(y) email account already exists. Email accounts are added sequentially by Outlook Express under the key:

"Software\Microsoft\Internet Account Manager\Accounts\00000001" (or 000000002 etc)

b) If 00000001 already exists, change the key "SMTP Server" to "smtp.domainname.com" and move on to 000000002 to see if that already exists. If it does not exist, write a couple registry keys for email settings.

c) If no email accounts exist, create the 00000001 entry and add subkeys, like:

POP3 Server
REG_SZ
mail.domain.com

POP3 User Name
REG_SZ
userinput@domain.com

POP3 Prompt for Password
REG_DWORD
0x0

SMTP Server
REG_SZ
mail.domain.com

SMTP Display Name
REG_SZ
User Input Name

SMTP Email Address
REG_SZ
userinput@domain.com


I used InstallOptions to create a page that has fields for them to type this information in. I am not sure how to "grab" this information and push it to the registry. If for example the fields are

Field 5: RealName
Field 6: email address

I have stuff like this in the function:

GetDlgItem $1 $hwnd 1204 ; Get RealName Input box (1200 + field 5 - 1)

But I'm not sure how to move stuff over to the registry. I'm reading as much as I can as fast as I can, but it's driving me nuts. :(


Mate you wanna check out Docs section 4.9.2.16 for how to write to the Registry.

To check if a key exists just use ReadRegStr on it, and if it returns "" and sets the error flag, it's not a key (if it returns a value but still sets the error flag then it's just a key of DWORD type, so check for both).

The way to check the error flag is this:


ClearErrors ; Resets the error flag
; -- Now do the bit with the reading the RegStr
IfErrors errorjump noerrorjump ; If there are errors jump to the errorjump label, otherwise jump to the noerrorjump label, shown below:

errorjump:
MessageBox MB_OK "Couldn't write to Registry!" ; or whatever

noerrorjump:
; Continue...


Hope this helps, a bit random I know!

-rob-