Function Reference

RegRead

Reads a value from the registry.

RegRead ( "keyname", "valuename" )

 

Parameters

keyname The registry key to read.
valuename The value to read.

 

Return Value

Success: Returns the requested registry value value..
Failure: Returns "" and sets the @error flag:
1 if unable to open requested key
-1 if unable to open requested value
-2 if value type not supported

 

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

AutoIt supports registry keys of type REG_BINARY, REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, and REG_DWORD.

To access the (Default) value use "" (a blank string) for the valuename.

When reading a REG_BINARY key the result is a string of hex characters, e.g. the REG_BINARY value of 01,a9,ff,77 will be read as the string "01A9FF77".

When reading a REG_MULTI_SZ key the multiple entries are seperated by @LF - use with StringSplit(..., @LF) to get each entry.

It is possible to access remote registries by using a keyname in the form "\\computername\keyname". To use this feature you must have the correct access rights on NT/2000/XP/2003, or if you are using a 9x based OS the remote PC must have the remote regsitry service installed first (See Microsoft Knowledge Base Article - 141460).

 

Related

RegDelete, RegWrite, StringSplit

 

Example


$var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
MsgBox(4096, "Program files are in:", $var)