Windows SDK Registry: How can I read data from the registry?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

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

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 04: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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center