网站首页  词典首页

请输入您要查询的函数:

 

术语 reggetvalue
释义 RegGetValue
语法:
C++
LONG WINAPI RegGetValue(
__in HKEY hkey,
__in_opt LPCTSTR lpSubKey,
__in_opt LPCTSTR lpValue,
__in_opt DWORD dwFlags,
__out_opt LPDWORD pdwType,
__out_opt PVOID pvData,
__inout_opt LPDWORD pcbData
);
RegGetValue功能
检索类型和指定的注册表值数据。
参数
hkey [in]
句柄到打开注册表项。密钥必须与已开放的KEY_QUERY_VALUE访问权限。有关更多信息,请参见注册表关键的安全和访问权限。
这种处理是由RegCreateKeyEx的,RegCreateKeyTransacted,RegOpenKeyEx,或RegOpenKeyTransacted函数返回。它也可以是下列预定义项之一:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_PERFORMANCE_DATA
HKEY_PERFORMANCE_NLSTEXT
HKEY_PERFORMANCE_TEXT
HKEY_USERS
lpSubKey [中,可选]
该注册表项的名称。这关键的必须是由指定的hKey参数项的子项。
键名不区分大小写。
lpValue [中,可选]
该注册表值的名称。
如果该参数为NULL或空字符串,“”,检索功能和数据类型的主要的未命名或默认值,如果有的话。
有关更多信息,请注册元素的大小限制。
钥匙不会自动拥有一个未命名或默认值。未命名的值可以是任何类型。
dwFlags [中,可选]
这些标志的限制值的数据类型的质疑。如果值的数据类型不符合这一标准,该功能失败。此参数可以是一个或多个下列值。
ValueMeaning
RRF_RT_ANY
0x0000ffffNo类型的限制。
RRF_RT_DWORD
0x00000018Restrict型32位RRF_RT_REG_BINARY | RRF_RT_REG_DWORD。
RRF_RT_QWORD
0x00000048Restrict型64位RRF_RT_REG_BINARY | RRF_RT_REG_DWORD。
RRF_RT_REG_BINARY
0x00000008Restrict类型REG_BINARY。
RRF_RT_REG_DWORD
0x00000010Restrict类型为REG_DWORD。
RRF_RT_REG_EXPAND_SZ
0x00000004Restrict type to REG_EXPAND_SZ.
RRF_RT_REG_MULTI_SZ
0x00000020Restrict类型均为REG_MULTI_SZ。
RRF_RT_REG_NONE
0x00000001Restrict类型为REG_NONE。
RRF_RT_REG_QWORD
0x00000040Restrict类型REG_QWORD。
RRF_RT_REG_SZ
0x00000002Restrict类型为REG_SZ。
此参数还可以包括一个或多个下列值。
ValueMeaning
RRF_NOEXPAND
0x10000000Do不会自动扩展环境字符串如果值的类型为REG_EXPAND_SZ的。
RRF_ZEROONFAILURE
0x20000000If pvData不为NULL,设置缓冲区的内容就失败零。
pdwType [指出,可选]
一项阿变量收到代码,以显示在指定的值存储的数据类型的指针。对于可能的类型代码清单,请参阅注册表值类型。此参数可以是NULL如果类型不是必需的。
pvData [指出,可选]
阿一个缓冲区,它接收值的数据指针。此参数可以是NULL如果数据不需要。
如果数据是一个字符串,为终止空字符的功能检查。如果没有找到,该字符串存储的空结束如果缓冲区足够大,以容纳额外的字符。否则,函数失败并返回ERROR_MORE_DATA。
pcbData [中,指出,可选]
一个变量,它指定的缓冲区大小的指针指向的pvData参数,以字节为单位。当函数返回时,该变量包含了复制到pvData数据的大小。
该pcbData参数可以是NULL,只有pvData为NULL。
如果数据是REG_SZ,均为REG_MULTI_SZ或REG_EXPAND_SZ类型,这样的规模包括任何终止空字符或字符。有关更多信息,请参见备注。
如果pvData参数指定的缓冲区不够大,无法容纳数据,该函数返回ERROR_MORE_DATA并存储在变量所需的缓冲区大小指向pcbData。在这种情况下,在pvData缓冲区的内容是不确定的。
如果pvData为NULL,pcbData不为NULL,则函数返回ERROR_SUCCESS并存储数据的大小,以字节的变量,指向pcbData。这使得一个应用程序,以确定最佳方式分配一个值的数据缓冲区。
如果hKey指定HKEY_PERFORMANCE_DATA和pvData缓冲区不够大,无法包含所有返回的数据,函数返回ERROR_MORE_DATA并通过pcbData参数返回的值是不确定的。这是因为性能数据的大小可以从一个电话改变未来。在这种情况下,您必须增加缓冲区的大小,并呼吁RegGetValue再次通过在pcbData参数更新的缓冲区大小。重复此,直到函数成功。您需要保持一个独立的变量来跟踪缓冲区的大小赛道,因为pcbData返回的值是不可预测的。
返回值
如果函数成功,返回值是ERROR_SUCCESS。
如果函数失败,返回值是一个系统错误代码。
如果pvData缓冲区太小,无法接受值,该函数返回ERROR_MORE_DATA。
备注
应用程序通常要求RegEnumValue,以确定该值名称,然后RegGetValue以检索数据的名称。
如果数据是REG_SZ,均为REG_MULTI_SZ或REG_EXPAND_SZ类型,此函数的使用ANSI版本(或者通过显式调用RegGetValueA或不明确之前,包括WINDOWS.H文件的UNICODE),这个函数转换成Unicode字符串存储到一个之前的ANSI复制到缓冲区字符串指向pvData。
当调用与hkey设置为HKEY_PERFORMANCE_DATA处理和一个指定的对象值的字符串这个函数,返回的数据结构有时未经请求的对象。不要惊讶,这是正常的行为。您应该总是期望步行返回的数据结构,寻找所请求的对象。
请注意,操作访问某些注册表项被重定向。有关更多信息,请在注册处注册,虚拟化和32位和64位应用程序数据。
要编译的应用程序使用此功能,定义_WIN32_WINNT为0x0600或更高版本。有关详细信息,请参阅使用Windows头。
要求:
最低支持clientWindows Vista中,Windows XP Professional x64版本
最低支持serverWindows Server 2008中时,Windows Server 2003 SP1的
HeaderWinreg.h(头文件:winuser.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode和ANSI namesRegGetValueW(Unicode)和RegGetValueA(ANSI)的
参见
RegCreateKeyEx的
RegEnumKeyEx
RegEnumValue
登记职能
注册表概述
RegOpenKeyEx
RegQueryInfoKey
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==RegGetValue Function
Retrieves the type and data for the specified registry value.
Syntax
C++
LONG WINAPI RegGetValue(
__in HKEY hkey,
__in_opt LPCTSTR lpSubKey,
__in_opt LPCTSTR lpValue,
__in_opt DWORD dwFlags,
__out_opt LPDWORD pdwType,
__out_opt PVOID pvData,
__inout_opt LPDWORD pcbData
);
Parameters
hkey [in]
A handle to an open registry key. The key must have been opened with the KEY_QUERY_VALUE access right. For more information, see Registry Key Security and Access Rights .
This handle is returned by the RegCreateKeyEx , RegCreateKeyTransacted , RegOpenKeyEx , or RegOpenKeyTransacted function. It can also be one of the following predefined keys :
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_PERFORMANCE_DATA
HKEY_PERFORMANCE_NLSTEXT
HKEY_PERFORMANCE_TEXT
HKEY_USERS
lpSubKey [in, optional]
The name of the registry key. This key must be a subkey of the key specified by the hkey parameter.
Key names are not case sensitive.
lpValue [in, optional]
The name of the registry value.
If this parameter is NULL or an empty string, "", the function retrieves the type and data for the key's unnamed or default value, if any.
For more information, see Registry Element Size Limits .
Keys do not automatically have an unnamed or default value. Unnamed values can be of any type.
dwFlags [in, optional]
The flags that restrict the data type of value to be queried. If the data type of the value does not meet this criteria, the function fails. This parameter can be one or more of the following values.
ValueMeaning
RRF_RT_ANY
0x0000ffffNo type restriction.
RRF_RT_DWORD
0x00000018Restrict type to 32-bit RRF_RT_REG_BINARY | RRF_RT_REG_DWORD.
RRF_RT_QWORD
0x00000048Restrict type to 64-bit RRF_RT_REG_BINARY | RRF_RT_REG_DWORD.
RRF_RT_REG_BINARY
0x00000008Restrict type to REG_BINARY.
RRF_RT_REG_DWORD
0x00000010Restrict type to REG_DWORD.
RRF_RT_REG_EXPAND_SZ
0x00000004Restrict type to REG_EXPAND_SZ.
RRF_RT_REG_MULTI_SZ
0x00000020Restrict type to REG_MULTI_SZ.
RRF_RT_REG_NONE
0x00000001Restrict type to REG_NONE.
RRF_RT_REG_QWORD
0x00000040Restrict type to REG_QWORD.
RRF_RT_REG_SZ
0x00000002Restrict type to REG_SZ.

This parameter can also include one or more of the following values.
ValueMeaning
RRF_NOEXPAND
0x10000000Do not automatically expand environment strings if the value is of type REG_EXPAND_SZ.
RRF_ZEROONFAILURE
0x20000000If pvData is not NULL, set the contents of the buffer to zeroes on failure.

pdwType [out, optional]
A pointer to a variable that receives a code indicating the type of data stored in the specified value. For a list of the possible type codes, see Registry Value Types . This parameter can be NULL if the type is not required.
pvData [out, optional]
A pointer to a buffer that receives the value's data. This parameter can be NULL if the data is not required.
If the data is a string, the function checks for a terminating null character. If one is not found, the string is stored with a null terminator if the buffer is large enough to accommodate the extra character. Otherwise, the function fails and returns ERROR_MORE_DATA.
pcbData [in, out, optional]
A pointer to a variable that specifies the size of the buffer pointed to by the pvData parameter, in bytes. When the function returns, this variable contains the size of the data copied to pvData.
The pcbData parameter can be NULL only if pvData is NULL.
If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, this size includes any terminating null character or characters. For more information, see Remarks.
If the buffer specified by pvData parameter is not large enough to hold the data, the function returns ERROR_MORE_DATA and stores the required buffer size in the variable pointed to by pcbData. In this case, the contents of the pvData buffer are undefined.
If pvData is NULL, and pcbData is non-NULL, the function returns ERROR_SUCCESS and stores the size of the data, in bytes, in the variable pointed to by pcbData. This enables an application to determine the best way to allocate a buffer for the value's data.
If hKey specifies HKEY_PERFORMANCE_DATA and the pvData buffer is not large enough to contain all of the returned data, the function returns ERROR_MORE_DATA and the value returned through the pcbData parameter is undefined. This is because the size of the performance data can change from one call to the next. In this case, you must increase the buffer size and call RegGetValue again passing the updated buffer size in the pcbData parameter. Repeat this until the function succeeds. You need to maintain a separate variable to keep track of the buffer size, because the value returned by pcbData is unpredictable.
Return Value
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is a system error code .
If the pvData buffer is too small to receive the value, the function returns ERROR_MORE_DATA.
Remarks
An application typically calls RegEnumValue to determine the value names and then RegGetValue to retrieve the data for the names.
If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, and the ANSI version of this function is used (either by explicitly calling RegGetValueA or by not defining UNICODE before including the Windows.h file), this function converts the stored Unicode string to an ANSI string before copying it to the buffer pointed to by pvData.
When calling this function with hkey set to the HKEY_PERFORMANCE_DATA handle and a value string of a specified object, the returned data structure sometimes has unrequested objects. Do not be surprised; this is normal behavior. You should always expect to walk the returned data structure to look for the requested object.
Note that operations that access certain registry keys are redirected. For more information, see Registry Virtualization and 32-bit and 64-bit Application Data in the Registry .
To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later. For more information, see Using the Windows Headers .
Requirements
Minimum supported clientWindows Vista, Windows XP Professional x64 Edition
Minimum supported serverWindows Server 2008, Windows Server 2003 with SP1
HeaderWinreg.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesRegGetValueW (Unicode) and RegGetValueA (ANSI)
See Also
RegCreateKeyEx
RegEnumKeyEx
RegEnumValue
Registry Functions
Registry Overview
RegOpenKeyEx
RegQueryInfoKey
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms724868(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:22:34