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 7912871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:42:40+00:00 2026-06-03T13:42:40+00:00

The below C++/CLI code returns nullptr to pKey. RegistryKey^ pKey = Microsoft::Win32::Registry::LocalMachine->OpenSubKey(SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Folders); The below

  • 0

The below C++/CLI code returns nullptr to pKey.

RegistryKey^ pKey = Microsoft::Win32::Registry::LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Folders");

The below C# code returns a valid pointer to pKey.

RegistryKey pKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Folders");

The two code snippets look the exact same to me besides the language differences.

I just figured out that building the C++ code in x64 allows it to find the key. So my question is now how can I find the key when in a 32 bit build? I need to find it in both builds.

Thanks.

  • 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. Editorial Team
    Editorial Team
    2026-06-03T13:42:41+00:00Added an answer on June 3, 2026 at 1:42 pm

    This is no doubt a side-effect of the platform target. On a 64-bit operating system, the HKLM/Software key gets redirected for 32-bit processes to HKLM/Software/Wow6432Node. Where that specific key you are looking for doesn’t exist.

    So odds are good that the C# code works because it targets AnyCPU and thus runs in 64-bit mode. And that the C++/CLI code doesn’t work because it targets Win32. There is no AnyCPU mode for C++/CLI, you explicitly have to choose between x64 and Win32. A side effect of C++/CLI assemblies containing native code.

    In .NET 4, the RegistryKey class got an extra OpenBaseKey() method that allows specifying the registry view. No simple workaround for earlier versions. Consider adding the x64 platform in your C++/CLI project. Or use the native winapi functions instead, C++/CLI’s strength.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have declared C++/CLI class as below namespace testcominterface { [ComVisible(true)] [Guid(FFCA805F-8DAB-4AF8-A7B7-B488136E8177)] public interface
Below is the code of my adapter that allows to create a popup with
Below is my code to download at client when user click on a download
Below is the code I have so far. I am trying to do the
Below is the code where it is displaying the delete message but it is
Below is partial code to an experimental http server app I'm building from scratch
I'm getting error C3095: 'Xunit::Extensions::InlineDataAttribute': attribute cannot be repeated in C++/CLI code but not
I have a small memory leak in my code regarding Strings in CLI/C++. I've
I'm referring the below code snippet from this link : while (1) { newsockfd
I am testing the code below, does a basic database query. It works fine

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.