[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to check a registry's data?

Posted on 2000-05-15
8
Medium Priority
?
351 Views
Last Modified: 2009-12-16
How can I check the content of the registry key I have created?

I have tried using "RegQueryValueKeyEx"
but can seems to work. Registry is not updated..

Any idea why?
0
Comment
Question by:raymondwee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 1

Expert Comment

by:yz
ID: 2810196
Please paste the code that you use to access the registry, or how can we know what happen.
0
 
LVL 1

Accepted Solution

by:
xutao earned 200 total points
ID: 2810220
The RegSetValueEx function sets the data and type of a specified value under a registry key.

LONG RegSetValueEx(
  HKEY hKey,           // handle to key
  LPCTSTR lpValueName, // value name
  DWORD Reserved,      // reserved
  DWORD dwType,        // value type
  CONST BYTE *lpData,  // value data
  DWORD cbData         // size of value data
);

The RegQueryValueEx function retrieves the type and data for a specified value name associated with an open registry key.

LONG RegQueryValueEx(
  HKEY hKey,            // handle to key
  LPCTSTR lpValueName,  // value name
  LPDWORD lpReserved,   // reserved
  LPDWORD lpType,       // type buffer
  LPBYTE lpData,        // data buffer
  LPDWORD lpcbData      // size of data buffer
);

And check the return value when you open or create a registry key.Notice: if you use null-terminated string containing the name of the subkey, double slash(\\) is needed.
0
 

Author Comment

by:raymondwee
ID: 2811075
My test application for registry manipulation is as attached below. Some of those codes are for debugging purposes.


                HKEY hKeyResult = 0;
      HKEY hKey = 0;
      DWORD dwDisposition = 0;
      char initial_value[2] = "0";
      char Reg_value[10] = "";
      DWORD Value = 0;
      DWORD value = 0;
      
      long CreateResult = RegCreateKeyEx(HKEY_CLASSES_ROOT,"Test",0,"",REG_OPTION_VOLATILE,KEY_ALL_ACCESS,NULL,&hKeyResult,&dwDisposition);
       
if(CreateResult != ERROR_SUCCESS)
      exit(0);

      long OpenResult = RegOpenKeyEx(HKEY_CLASSES_ROOT,"Test",0,KEY_QUERY_VALUE,&hKey);

      long SetResult = RegSetValue(hKeyResult,NULL,REG_SZ,"8",1);

      RegQueryValueEx(hKeyResult,"",NULL,NULL,(LPBYTE)Reg_value,&Value);

      if(!strcmp(Reg_value,"8"))
            exit(0);
      value = atol(Reg_value) + 1;

      SetResult = RegSetValue(hKeyResult,NULL,REG_SZ,Reg_value,1);

      if(SetResult != ERROR_SUCCESS)
            exit(0);

      RegCloseKey(hKeyResult);
      RegCloseKey(hKey);
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:yz
ID: 2812729
Add Value = sizeof(Reg_value) before RegQueryValueEx.
0
 
LVL 1

Expert Comment

by:yz
ID: 2812731
long SetResult = RegSetValue(hKeyResult,NULL,REG_SZ,"8",1);

//////// Add this

Value = sizeof(Reg_value);


RegQueryValueEx(hKeyResult,"",NULL,NULL,(LPBYTE)Reg_value,&Value);

you'd better check the return value of RegQueryValueEx, it can tell why the function failed.
0
 

Author Comment

by:raymondwee
ID: 2812861
Thanks xutao and yz for your answers.

I can update the registry now.

yz, why does it work if the Value = sizeof(....) is added before the Query...

Pls email me at raymondwee@pmail.ntu.edu.sg.

Thanks again.
0
 
LVL 1

Expert Comment

by:yz
ID: 2820699
Paste a part of the description of the RegQueryValueEx from MSDN below.
----------------------------------
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.
----------------------------------
notice the variable lpcbData is [in/out], it means you should give is a exectly value when call the function, if need, the function will give you back a new value.
0
 

Author Comment

by:raymondwee
ID: 2821001
ooooic.
thx again
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question