PDA

View Full Version : Help for setting registry values - Merge Module



DLee65
11-09-2005, 11:09 AM
I am new to Basic MSI installations but not to InstallScript.

I am creating a merge module that includes a single custom dialog that contains a single text field. The merge module will write the value of this dialog to a specific location in the registry. However, I want to leave open the possibility of having more than one entry into this registry key.

For example:
HKLM\Software\Company\Product\SubProduct\ would be the key. Under this key can be any number of existing keys:
Key0, Key1, Keyn, etc.
The value for each key will be different.
I need to do the following:

1. Ensure that the value entered has not already been entered (need to query all keys)
2. If the value entered is unique, then I add a new enumerated key, and assign this new value.
3. The process will continue for each value the user wants to enter or until the user clicks on NEXT.

Optionally, I want to include the ability to read the values from a text file, (CSV Delimited), and skip this dialog all together.

So, now that you understand the requirements (sort of), is there a way to setup the Registry System configuration to respond to a custom action like this and to add a new registry value at runtime?

Secondly, for the optional item described above, can I (using basic msi scripts only) read a value from a command line and set properties based on this command line value. This will allow me to determine if I should show the dialog or not.

Thanks.
Dan

DLee65
11-09-2005, 04:02 PM
Ok, here is my code to generate an array of items:


<vbscript>
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\DeLorme\Earthmate\PN-20\"
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes

For i=0 To UBound(arrValueNames)
WScript.Echo "File Name: " & arrValueNames(i)
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,_
arrValueNames(i),strValue
WScript.Echo "Location: " & strValue
Next

DLee65
11-18-2005, 04:48 PM
Ok, the requirements have changed some. I have a dialog (within the merge module) that contains a text field, a list box, a pushbutton to add a value to the list, and a push button to remove a value from the list.

Basically, when the dialog loads, I need to do the following:
1. Build a list of values based on registry entries (from array above).
2. Display list of values in list box.
3. If user types a value into the text field and clicks on the Add pushbutton, then the list gets updated to add the current value to the list.
4. If user selects an item from the list the value is removed from the list.
5. When user clicks on Next the list of values is stored and written to the registry during the execute phase.

Some of the steps I am trying to research is:
1. How to populate the list box at runtime
2. How to append / modifiy this list.

Does anyone have any good links on how to handle these situations? Thanks.

RobertDickau
11-18-2005, 04:58 PM
For populating a list box at run time, perhaps see this DevLetter tip: http://www.installshield.com/news/newsletter/0302-articles/msiaccess.asp.

As for more list-box manipulation at run time, I haven't looked at it myself, but perhaps see this article by Stefan Krueger: www.installsite.org > Windows Installer > Technical Articles > Using Dual ListBoxes as Replacement for a Multi-Selection ListBox.