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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Is this what you are trying to accomplish? Or do… May 11, 2026 at 3:29 pm
  • added an answer From the GNU diff documentation: Handling Multibyte and Varying-Width Characters… May 11, 2026 at 3:29 pm
  • added an answer you would have to do SELECT TOP 1 ID FROM… May 11, 2026 at 3:29 pm

Related Questions

I'm trying to get a simple mixture between Managed C++ and plain C++ working.
I have a C++ DLL (no code) that I want to expose to .NET
I'm trying to run msbuild on a solution that has some C++ code in
Saludos a todos en stackoverflow.com!! So... I'm a C++ newbie currently taking the subject

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.