Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
DWORD dwType = REG_DWORD;
size1=1024;	
			
if((RegQueryValueEx(keyHandle,"Value",NULL,&dwType,(LPBYTE)rgValue1,&size1))
SetDlgItemText(IDC_EDIT, rgValue1);


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
Posted
Updated 6-Jul-15 22:09pm
v2
Comments
Richard MacCutchan 7-Jul-15 4:16am    
Check the return value from the function call to see what the error is. You also should note that you cannot use SetDlgItemText with a DWORD value, you should use SetDlgItemInt.

The return value is
VB
ERROR_SUCCESS 0 (0x0)
if no errors occurs!

You need to change

C++
if((RegQueryValueEx(keyHandle,"Value",NULL,&dwType,(LPBYTE)rgValue1,&size1))

with
C++
if(RegQueryValueEx(keyHandle,"Value",NULL,&dwType,(LPBYTE)rgValue1,&size1 == ERROR_SUCCESS)
 
Share this answer
 
v2
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)
C++
    DWORD dwData;
DWORD cbData = sizeof(DWORD);
DWORD dwRet;
   dwRet = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
                     TEXT("Global"),
                     NULL,
                     NULL,
                     (LPBYTE)&dwData,
          &cbData );
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900