RegWrite Method

 

Description

 

Creates a new key, adds another value-name to an existing key (and assigns it a value), or changes the value of an existing value-name.

 

PowerBASIC Syntax

 

METHOD RegWrite ( _

BYVAL bstrName AS STRING, _

BYREF vValue AS VARIANT, _

OPTIONAL BYREF vType AS VARIANT _

)

 

Arguments

 

bstrName

BSTR. String value indicating the key-name, value-name, or value you want to create, add, or change.

vValue

VARIANT. The name of the new key you want to create, the name of the value you want to add to an existing key, or the new value you want to assign to an existing value-name.

vType

Optional. VARIANT. String value indicating the value's data type.

 

Remarks

 

Specify a key-name by ending strName with a final backslash. Do not include a final backslash to specify a value name. The RegWrite method automatically converts the parameter anyValue to either a string or an integer. The value of vType determines its data type (either a string or an integer). The options for vType are listed in the following table.

 

Converted to

bstrType

String

REG_SZ

String

REG_EXPAND_SZ

Integer

REG_DWORD

Integer

REG_BINARY

 

Note. The REG_MULTI_SZ type is not supported for the RegWrite method.

 

Tip  RegWrite will write at most one DWORD to a REG_BINARY value. Larger values are not supported with this method.

 

Fully qualified key-names and value-names are prefixed with a root key. You may use abbreviated versions of root key names with the RegWrite method. The five root keys are listed in the following table.

 

Root key Name

Abbreviation

HKEY_CURRENT_USER

HKCU

HKEY_LOCAL_MACHINE

HKLM

HKEY_CLASSES_ROOT

HKCR

HKEY_USERS

HKEY_USERS

HKEY_CURRENT_CONFIG

HKEY_CURRENT_CONFIG

 

The four possible data types you can specify with vType are listed in the following table.

 

Type

Description

In the Form of

REG_SZ

A string

A string

REG_DWORD

A number

An integer

REG_BINARY

A binary value

An integer

REG_EXPAND_SZ

An expandable string (e.g., "%windir%\\calc.exe")

A string

 

Example [PowerBASIC]

 

#INCLUDE "WSHOM.INC"

 

DIM pWsh AS IWshShell

DIM vValue AS VARIANT
DIM vType AS VARIANT

pWsh = NEWCOM "WScript.Shell"
vValue = 1 AS LONG
vType = "REG_BINARY"
pWsh.RegWrite UCODE$("HKCU\Software\ACME\FortuneTeller\"), vValue, vType
vValue = "Goocher!"
vType = "REG_SZ"
pWsh.RegWrite UCODE$("HKCU\Software\ACME\FortuneTeller\MindReader"), vValue, vType

 

Valid XHTML 1.0 Transitional