如何读取registrykey REG_DWORD值 [英] how to read the registrykey REG_DWORD value
本文介绍了如何读取registrykey REG_DWORD值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DWORD dwType = REG_DWORD;
size1=1024;
if((RegQueryValueEx(keyHandle,"Value",NULL,&dwType,(LPBYTE)rgValue1,&size1))
SetDlgItemText(IDC_EDIT, rgValue1);
我想读取一个DWORD类型的registrykey(值)并希望在编辑框中显示它,但RegQueryValueEx函数返回空值。请帮助我
I want to read a registrykey(value) which is of DWORD type and want to display it in the editbox but RegQueryValueEx function returns empty value.please help me
推荐答案
返回值是
ERROR_SUCCESS 0 (0x0)
如果没有发生错误!
您需要更改
if no errors occurs!
You need to change
if((RegQueryValueEx(keyHandle,"Value",NULL,&dwType,(LPBYTE)rgValue1,&size1))
with
with
if(RegQueryValueEx(keyHandle,"Value",NULL,&dwType,(LPBYTE)rgValue1,&size1 == ERROR_SUCCESS)
如果你读到这个: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724911(v = vs.85).aspx [ ^ ]
和这个:
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-us/ 21c791ad-f1f3-4941-8ddc-8443447403c5 / how-to-use-regqueryvalueex-function-to-query-a-regdword-value-?forum = windowsgeneraldevelopmentissues [ ^ ]
你需要这样的东西(仅举例)
If you read this: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724911(v=vs.85).aspx[^]
and this:
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-us/21c791ad-f1f3-4941-8ddc-8443447403c5/how-to-use-regqueryvalueex-function-to-query-a-regdword-value-?forum=windowsgeneraldevelopmentissues[^]
You will need something like this (example only)
DWORD dwData;
DWORD cbData = sizeof(DWORD);
DWORD dwRet;
dwRet = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
TEXT("Global"),
NULL,
NULL,
(LPBYTE)&dwData,
&cbData );
这篇关于如何读取registrykey REG_DWORD值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文