Archive: Using SHCTX


Using SHCTX
Hi, I am new to NSIS. I am building some installs for some programs and found out about this, and using the HM NIS Editor. It looks great.

One thing I do not know how to do is mimic the behavior of the Windows Installer on the Directory page that presents the user with two radio buttons labeled "Everyone" and "Just Me". I can see from using the wizard that the root key is being set to default as "HKLM". I have searched through these forums and seen a description of using "SHCTX" and "SetShellVarContext", but I don't really understand how I am supposed to get that input from the user.

So my questions are:
1. Are there any new examples that show exactly how to get the user to input whether he or she wants to install in HKCU or HKLM, and then to set that variable?

2. Is there a way to add those two radio buttons to the MUI_PAGE_DIRECTORY dialog for the user to make that decision?

Thanks in advance for any answers or pointers to samples!
Bill


You would have to add the radio buttons with Resource Hacker, and then you need to find out which one is checked in the page's Leave function using SendMessage.

You could create a variable with Var and store say 0 or 1 in it (the state from the radio buttons would be easiest) and then in the sections use StrCmp to call WriteRegStr's on HKLM or HKCU.

-Stu


Hmm, that sounds more complicated than I thought it would be. I will try to do what you suggested, thanks. Are there any samples of someone doing this? I would have to make a custom form, no? I can't just add to the MUI_PAGE_DIRECTORY form that comes with NSIS?


Yes you can add radio buttons with Resource Hacker like I said. Just search for the name on Google. You'd need to make a copy of Contrib\UIs\modern.exe and place the copy in the same folder as your script.
Then use !define MUI_UI modern.exe to use the new copy.

Open modern.exe in Resource Hacker and you need to open up dialog ID 103. Add the radio buttons, then click Compile and then Save. Make sure you give them both a unique control number. 8 and 9 haven't been used yet.

To find out if one of them is checked or not, you need to use SendMessage with the appropriate windows message. This works for check boxes, but I doubt the same message (0x00F2) will work for radio buttons as well:

FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 8
SendMessage $R0 0x00F2 0 0 $R0
StrCmp $R0 1 0 +2
MessageBox MB_OK "Checked!"

-Stu


would be much easier to add a custom page with install options.


Thanks for the replies!

Unfortunately, this, and a couple of other little cutomizations were too difficult for me to do (I'm a newb). It seems like this should be an attribute added to the form like the other things. It was taking me a while to figure out, and because of the delay my boss ORDERED me to drop this NSIS 'stuff' and use the 'WiX' Windows Installer XML toolset instead.

Cheers!
Bill