Valid on Windows
The RegSetVariable function stores a variable in the specified registry key.
Function format:
RegSetVariable(hKey as Integer, name as String, value as Integer) as Boolean
RegSetVariable(hKey as Integer, name as String, value as String) as Boolean
RegSetVariable(hkey as integer, name as string, buffer as void, bufsize as integer) as integer.
RegSetVariable(hkey as integer, name as string, buffer as void, bufsize as integer, type as integer) as integer.
Identifies a currently open key or a predefined key. The hKey parameter can have one of the following predefined values:
HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
Identifies the name of the variable that is to be set.
Identifies the string or Integer value that is to be set in the variable.
Buffer containing the value to be set in the variable.
Size of the buffer in chars if the buffer is of type string or array of type char; otherwise, the number of bytes are specified.
The type of registry entry.
Type of registry entry is returned in Microsoft notation:
Value 0
Value 1
Value 2
Value 3
Value 4
Value 5
Value 6
Value 7
Value 8
On successful completion, the function returns TRUE; otherwise, it returns FALSE.
Example:
Before you start the following example, run the RegOpenKey example.
Dim value as string
Dim hkey1 as integer
Dim name, str, dummy as string
Dim i, i1, rtr, int as integer
Dim bBuf[100] as Byte
Dim cBuf[100] as char
ClrScr()
hkey1 = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\CA\4 test only")
if hkey1 = 0 then
Print("RegOpenKey failed.")
exit
endif
rtr = RegQueryVariable(hkey1, "var_2", str, int)
Print(Str(rtr) + ": var_2 = " + str)
int = 100
str = ""
rtr = RegQueryVariable(hkey1, "var_2", dummy, int, str)
Print(Str(rtr) + ": var_2(" + Str(int) + ") = " + str)
int = 100
str = ""
rtr = RegQueryVariable(hkey1, "var_2", dummy, int, cBuf)
for i1 = 0 to int - 1
str = str + cBuf[i1]
next i1
Print(Str(rtr) + ": var_2(" + Str(int) + ") = " + str)
int = 100
str = "| "
rtr = RegQueryVariable(hkey1, "var_2", dummy, int, bBuf)
for i1 = 0 to int - 1
str = str + Str(bBuf[i1]) + " | "
next i1
Print(Str(rtr) + ": var_2(" + Str(int) + ") = " + str)
RegCloseKey(hkey1)
|
Copyright © 2014 CA Technologies.
All rights reserved.
|
|