Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 159555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:52:48+00:00 2026-05-11T10:52:48+00:00

Im trying to code a Visual C++ 2005 routine that checks the registry for

  • 0

Im trying to code a Visual C++ 2005 routine that checks the registry for certain keys/values. I have no trouble in writing code using c# but I need it in C++. Anybody know how to do this using c++ in vs2005.

Many thanks Tony

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:52:48+00:00Added an answer on May 11, 2026 at 10:52 am

    Here is some pseudo-code to retrieve the following:

    1. If a registry key exists
    2. What the default value is for that registry key
    3. What a string value is
    4. What a DWORD value is

    Example code:

    Include the library dependency: Advapi32.lib

    Put the following in your main or where you want to read the values:

    HKEY hKey; LONG lRes = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L'SOFTWARE\\Perl', 0, KEY_READ, &hKey); bool bExistsAndSuccess (lRes == ERROR_SUCCESS); bool bDoesNotExistsSpecifically (lres == ERROR_FILE_NOT_FOUND); std::wstring strValueOfBinDir; std::wstring strKeyDefaultValue; GetStringRegKey(hKey, L'BinDir', strValueOfBinDir, L'bad'); GetStringRegKey(hKey, L'', strKeyDefaultValue, L'bad'); 

    Put these wrapper functions at the top of your code:

    LONG GetDWORDRegKey(HKEY hKey, const std::wstring &strValueName, DWORD &nValue, DWORD nDefaultValue) {     nValue = nDefaultValue;     DWORD dwBufferSize(sizeof(DWORD));     DWORD nResult(0);     LONG nError = ::RegQueryValueExW(hKey,         strValueName.c_str(),         0,         NULL,         reinterpret_cast<LPBYTE>(&nResult),         &dwBufferSize);     if (ERROR_SUCCESS == nError)     {         nValue = nResult;     }     return nError; }   LONG GetBoolRegKey(HKEY hKey, const std::wstring &strValueName, bool &bValue, bool bDefaultValue) {     DWORD nDefValue((bDefaultValue) ? 1 : 0);     DWORD nResult(nDefValue);     LONG nError = GetDWORDRegKey(hKey, strValueName.c_str(), nResult, nDefValue);     if (ERROR_SUCCESS == nError)     {         bValue = (nResult != 0) ? true : false;     }     return nError; }   LONG GetStringRegKey(HKEY hKey, const std::wstring &strValueName, std::wstring &strValue, const std::wstring &strDefaultValue) {     strValue = strDefaultValue;     WCHAR szBuffer[512];     DWORD dwBufferSize = sizeof(szBuffer);     ULONG nError;     nError = RegQueryValueExW(hKey, strValueName.c_str(), 0, NULL, (LPBYTE)szBuffer, &dwBufferSize);     if (ERROR_SUCCESS == nError)     {         strValue = szBuffer;     }     return nError; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in Visual Studio 2005. Dim OutFile As System.IO.StreamWriter Try
I am using C# and Visual Studio 2005. I have created multiple Texboxes at
I am trying to make some optimized code using SSE2 instructions. Currently, i have
Does anyone have experience using makefiles for Visual Studio C++ builds (under VS 2005)
I'm trying to compile the code in Visual Studio (2008) and g++. In vs2008
Begginer's question. I'm trying to write small piece of code in Visual Studio (VB.net)
I'm trying to compile with g++ some code previously developed under Visual C++ 2008
I am walking through a Visual FoxPro program trying to document the code in
I´m trying to code a tooltip (Yes I know, I have my reasons to
I am trying to code AES using Cipher Block Chaining(CBC) mode. I am pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.