Valid on Windows
The RegQueryVariable function retrieves the type and value of the specified variable for the specified registry key.
Function format:
Format 1
RegQueryVariable(hKey as Integer, name as String, strvalue as String, intvalue 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 requested variable.
Identifies the output parameter that is to hold the string value of the requested variable.
Identifies the output parameter that is to hold the integer value of the requested variable.
On successful completion, the function returns one of the following values:
A variable was not found. This indicates that the handle was invalid.
An integer type variable was found; the value will be stored in the intvalue variable.
A string type variable was found; the value will be stored in the strvalue variable.
An unsupported variable type was found; the value will be void.
Format 2
RegQueryVariable(hkey as integer, name as string, dummy as string, bufsize as integer, buffer as void) 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 requested variable.
Reserved.
Size of the receiving buffer in chars if the buffer is of type string; otherwise, the number of bytes are specified. Must be a variable. After successful return it contains the number of bytes retrieved.
Buffer to receive the retrieved value of the variable.
Type of registry entry is returned in Microsoft notation:
Value 1
Value 2
Value 3
Value 4
Value 5
Value 6
Value 7
Value 8
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.
|
|