RegSetValue

Sets the value of a data item in the Registration Database.

Syntax:

RegSetValue(handle, subkey-string, value [,view-flag])

Parameters:

(i) handle handle to a registration database key.

(s) subkey-string a path from the key provided to the desired key, including the "data item name" in square brackets
at the end of the key string.

(s) value data to be stored into the database at desired key.

(i) view-flag [optional] controls which registry view the function uses when accessing the Windows registry.
0 - view indicated by the last call to the RegOpenFlags.
32 - use the 32-bit registry view.
64 - use the 64-bit registry view.

Returns:

(i)  @TRUE data item was stored; @FALSE operation failed.

 

Use this function to store data items into the Registration Database. If the desired key does not exist, the function will create it.

Note: Named data entries are specified by enclosing the data item name in square brackets at the end of the key string. For example:


RegSetValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\Settings\WWWBATCH\MAIN[SOUNDS]",1)

View-flag

This optional parameter controls which registry view the function uses when accessing the Windows registry. The optional parameter's values can be 32 to use the 32-bit view, 64 to use the 64-bit view, or 0 to use the view indicated by the last call to the RegOpenFlags. The parameter value of 0 can also causes a function to use the WinBatch default 64-bit view, if no call to RegOpenFlags has been made and setting the parameter to 0 is equivalent to omitting the parameter entirely.

Notes:

Windows Vista/2008 and newer: This function may require an Administrator level account, if it attempts to access protected registry keys: HKEY_LOCAL_MACHINE  or HKEY_CLASSES_ROOT.

 
Example:

; Associate DIZ files with the default textfile editor
key=RegCreateKey(@REGCLASSES, ".diz")
RegSetValue(key, "", "txtfile")
RegCloseKey(key)
; The preceding is actually a hard way to do ...
RegSetValue(@REGCLASSES, ".diz", "txtfile")
Message("RegSetValue","Done")

See Also:

RegQueryValue, RegApp, RegEntryType, RegSetBin, RegSetDword, RegSetEx, RegSetExpSz and the section on Registration Database Operations