CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Windows SDK Registry: How can I read in data from the registry?

    Q: How can I read data from the registry?

    A:

    Code:
    HKEY  hKey;
    DWORD dwSize     = 0;
    DWORD dwDataType = 0;
    DWORD dwValue    = 0;
    
    if(::RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                      "System\\CurrentControlSet\\Control\\Windows",
                      0,
                      KEY_QUERY_VALUE,
                      &hKey) == ERROR_SUCCESS)
    {
      // Get CSD version
      dwSize = sizeof(dwValue);
    
      if(::RegQueryValueEx(hKey,
                           "CSDVersion",
                           0,
                           &dwDataType,
                           reinterpret_cast<BYTE *>(&dwValue),
                           &dwSize) != ERROR_SUCCESS)
      {
        // Close key
        ::RegCloseKey(hKey);
    
        // Error handling
      }
      else
      {
        // Work with value
        // Close key
        ::RegCloseKey(hKey);
      }
    }
    else
      // Error handling;
    Last edited by Andreas Masur; July 25th, 2005 at 03:11 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured