Win32 SDK Registry Operation - REGQUERYVALUEEX

zhaozj2021-02-08  211

RegQueryValueex

(For more information, http://websl.126.com)

RegQueryValueex retrieves the type and data of a given value associated with the open registry key.

Long RegQueryValueex (

HKEY HKEY, / / ​​Handle to query the key

LPTSTR LPVALUENAME, / / ​​To query the address of the name of the value

LPDWORD LPRESERVED, / /

LPDWORD LPTYPE, / / ​​Value Cache Address

LPBYTE LPDATA, // Data Cache Address

LPDWORD LPCBDATA // Data Cache Size Address

);

parameter

HKEY

A handle of the currently opened button or the following already defined reserved handle value:

HKEY_CLASS_ROTHKEY_CURRENT_CONFIGHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_USERSWINDOWS NT: HKEY_PERFORMANCE_DATA Windows 95 and Windows 98: HKEY_DYN_DATA

LPVALUENAME

Point to the string of the name to be queried (end with empty characters).

If LPVALUENAME is NULL or an empty string (""), this function retrieves the type and data of the unnamed or default value of this key.

Windows 95 and Windows 98: Each key has a default (initially does not contain data). In Windows 95, this person's default value is always reg_sz. In Windows 98, the default key is initially REG_SZ, but you can specify a default value different from RegSetValueex.

Windows NT: Keys cannot automatically have an unnamed or default value, and unnamed values ​​can be any type.

LPRESERVED

Reserved, must be NULL.

LPTYPE

Point variables to the type associated with the given value. This value will be returned by this parameter, which will be one of the following:

The value of REG_BINARY binary data. REG_DWORD A 32-bit number. REG_DWORD_LITTLE_ENDIAN A Little-Endian format 32 digit. This is equivalent to REG_DWORD. Little-endian format, is a multi-byte value being stored from low bytes to high byte in memory. For example, value 0x12345678 is stored in the Little-Endian format (0x78 0x56 0x34 0x12). Windows NT, Windows 95, and Windows 98 are intended to run on the Little-Endian computer system. For example, like some UNIX systems, one user must connect to a computer of a BIG-Endian system. REG_DWORD_BIG_ENDIAN 32 digits in a BIG-Endian format. Big-endian format, a multi-byte value is stored from high bytes to low byte storage from high bytes. For example, value 0x12345678 is stored in a Big-endian format (0x12 0x34 0x56 0x78). REG_EXPAND_SZ A string (e.g., "% PATH%") that contains empty characters containing untruritable environment variables. It is a Unicode string or an ANSI string will depend on the Unicode function or an ASI function. Extended environment variables, use the ExpandenVironmentStrings function. REG_LINK A Unicode symbol connection. REG_MULTI_SZ An array of strings ended with empty characters and ends by two NULL characters. REG_NONE is not defined. REG_RESOURCE_LIST A list of devices drive resources. REG_SZ A string ended with empty characters. It is a Unicode string or an ANSI string will depend on the Unicode function or an ASI function. If the type LPTYPE parameter is not required, it can be empty.

LPDATA

Specifies the cache area for receiving value data. If the data is not required, this parameter can be empty.

LPCBDATA

In-byte, pointing

The LPDATA parameter specifies the variable of the cache size. Function returns to copy

LPDATA variables of data size.

If the data is a REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, then LPCBDATA will also include the size of the empty character.

If LPDATA is NULL, the LPCBData parameter can be NULL.

If the cache specified by the LPDATA parameter is not large enough, this function returns an error_more_data value and retrieves the size (in byte) of the variable cache specified by lpcbdata.

If lpdata is null, lpcbdata is not null, this function returns ERROR_SUCCESS and retrieves the size of the variable cache specified by lpcbdata (in bytes). This value of data cache is allocated the best way.

Window NT: If HKEY is specified as HKEY_PERFORMANCE_DATA, and the LPDATA cache is too small, RegQueryValueex returns ERROR_MORE_DATA, but LPCBData cannot return the required cache size. This is because the size of the data can be changed in the next step of the call. In this case, you must add the size of the cache and re-call RegQueryValueex update the cache size through the LPCBData parameter. Repeat until the function is successful. You need to maintain a separate variable to pay attention to the size of the cache. The value returned by LPCBDATA is not predictable.

return value

If this function is successful, return ERROR_SUCCESS.

If you have failed, return a non-zero error code (defined in Winerror.h). You can use the FormatMessage function with the format_message_from_system tag to get the wrong universal description information.

note

The key determined by HKEY must be opened by the key_query_value tag. Open key, use the RegcreateKeyex function or RegopenKeyex function. If the value data is the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, the ANSI version of this function will be used (clear call regqueryvalueexa or do not define Unicode before containing Windows.h files), which is previously replicated to the cache to LPDATA specified. Conversion storage Unicode string is an ANSI string.

WINDOW NT: When the regqueryvalueex function is called and HKEY is set to the HKEY_PERFORMANCE_DATA handle, the returned data structure is often an undefined object when the value of the object is set. Don't be surprised; this is normal. When the RegQueryValueex function, You Should Always Expect to Walk The Returned Data Structure to Look for the Requested Object.

Quick information

Windows NT: It takes 3.1 or higher. Windows: Need Windows 95 or higher. Windows CE: 1.0 or higher. Header file: WinReg.h. Enter the library: Advapi32.lib. Unicode: Performed as Unicode or ANSI in Windows NT.

See

REGISTRY FUNCTIONS, EXPANDENVIRONMENTSTRINGS, RegcreateKeyex, RegenumKey, Regenkeyex, RegenumValue, Regopenkeyex, RegQueryInfoKey, RegQueryValue

转载请注明原文地址:https://www.9cbs.com/read-3385.html

New Post(0)