如何对注册表中键值为二进制的数据进行读取???

codica 2000-12-30 09:32:00
请问如何对注册表中键值为二进制的数据进行读取,我现在知道用RegOpenKeyEx(),RegQueryValueEx()来读取,问题出在
LONG RegQueryValueEx(
HKEY hKey, // handle to key to query
LPTSTR lpValueName, // address of name of value to query
LPDWORD lpReserved, // reserved
LPDWORD lpType, // address of buffer for value type
LPBYTE lpData, // address of data buffer
LPDWORD lpcbData // address of data buffer size
);
lpData,lpcbData这两个参数的类型分别应该为什么?
能否详细说明二进制数据(在注册表中是以16进制的方式给出的)在参数
中的存储方式.
谢谢!!!
...全文
202 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Fesd 2001-01-03
  • 打赏
  • 举报
回复
lpData
[in, out] Pointer to a buffer that receives the value's data. This parameter can be NULL if the data is not required.
lpcbData
[in/out] Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the lpData parameter. When the function returns, this variable contains the size of the data copied to lpData.
If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, then lpcbData will also include the size of the terminating null character.

The lpcbData parameter can be NULL only if lpData is NULL.

If the buffer specified by lpData parameter is not large enough to hold the data, the function returns the value ERROR_MORE_DATA, and stores the required buffer size, in bytes, into the variable pointed to by lpcbData. In this case, the contents of the lpValue buffer are undefined.

If lpData is NULL, and lpcbData is non-NULL, the function returns ERROR_SUCCESS, and stores the size of the data, in bytes, in the variable pointed to by lpcbData. This lets an application determine the best way to allocate a buffer for the value's data.

Window NT: If hKey specifies HKEY_PERFORMANCE_DATA and the lpData buffer is too small, RegQueryValueEx returns ERROR_MORE_DATA but lpcbData does not return the required buffer size. 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 RegQueryValueEx again passing the updated buffer size in the lpcbData 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 lpcbData is unpredictable.

adrianx 2000-12-30
  • 打赏
  • 举报
回复
你想读取多大的值
lpData是你分配的一段BYTE类型的内存,用来存放键值的数据
lpcbData是你所获得的数据的字节数是个DWORD类型的指针
----
至于二进制数据的存储方式,我认为你要多看些基础的知识
狐帝 2000-12-30
  • 打赏
  • 举报
回复
lpData是字节数组首地址,用于存放读出的数据。
lpcbData是DWORD指针,用于返回读出的数据的字节数。

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧