Link to home
Start Free TrialLog in
Avatar of corduroy9
corduroy9

asked on

Query Registry for Specific Value

Hi,

Using C++ I need some code to find a specific value of a key.

So for example, if I have ...\....\....\...\IBM

Inside that folder one of the keys is called Vaild.  I need to get the 'Data' or value back.

How would you go about this?
Avatar of jkr
jkr
Flag of Germany image

You could use

   REGSAM sam = KEY_ALL_ACCESS;
   char* pszKey = "...\\....\\....\\...\\IBM";

   if ( ERROR_SUCCESS != RegOpenKeyEx ( HKEY_LOCAL_MACHINE, pszKey, 0, sam, &hKey)) {

      return; // nothing to do...
   }

   DWORD dwType = REG_DWORD;
   DWORD dwSize = sizeof ( DWORD);
   DWORD dwValue;

   if ( ERROR_SUCCESS == RegQueryValueEx (
                                hKey,
                                "Valid",
                                NULL,
                                &dwType,
                                ( LPBYTE) &dwValue,
                                &dwSize)
                               ) {

   }

   RegCloseKey ( hKey);

}
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial