-1

I'm running the latest version of Visual Studio C++ desktop with the latest v4.8.04084 version of .NET Framework, and in a header file I have #include <Windows.h> followed later by "using Microsoft.Win32". Here "Microsoft" gets the red squiggly underline. Without the Microsoft prefix, "Win32" also gets the red squiggly line. "identifier "Microsoft" is undefined, etc.

Evidently, Visual Studio can't find where these two are defined. Please note that "Windows.h" shows up in the project's "External Dependencies" list. It would appear, then, that the missing identifiers are not defined in Windows.h or in winreg.h, which is included in Windows.h. Having spent days trying to find the files in which these identifiers are defined, I am at a loss.

My aim is to be able to edit values in the registry. Does anyone know where the identifiers "Microsoft", "Win32", and "Microsoft.Win32" are defined?

I tried many searches on the Internet for answers to this question. Chat GPT said that these identifiers should be defined in winreg.h. No such luck.

Also, no luck with Visual Studio 2017.

  • 3
    It seems you're mixing your languages and frameworks here. C++ is not C#, not even the same as C++/CLI. C++ doesn't have anything to do with .NET or .NET namespaces. – Some programmer dude Sep 02 '23 at 09:26
  • I'm also very curious what learning or teaching resources you're using to learn about these things? What are they really teaching you? – Some programmer dude Sep 02 '23 at 09:27
  • 1
    If you are going to use C++ then you will need to use the windows API (you cannot use any of the .Net classes like you are trying to do). [Use modern C++ to access the windows registry](https://learn.microsoft.com/en-us/archive/msdn-magazine/2017/may/c-use-modern-c-to-access-the-windows-registry) – Pepijn Kramer Sep 02 '23 at 10:15
  • I appreciate the quick responses from @Some programmer dude and Pepijn Kramer. You have given me the clues that I needed. Being self-taught, I'll admit that the teacher in this case is inept, and I wouldn't recommend him to anybody. For many years, I have relied on online resources like Stackoverflow and have never before had to ask a question. For others like myself, I will try to give a clear presentation of the answer. – user22487671 Sep 02 '23 at 21:05
  • @Pepijn Kramer, now I see that the winreg.h resource downloaded with the C++ desktop Windows version of Visual Studio is completely different from the winreg.h resource referred to by Chat GPT. The former has a bunch of C functions that can be used for registry manipulations. The latter presumably has the more attractive C++-like members that are only usable in .NET implementations (C#) and not in C++. Please correct me if I am wrong. – user22487671 Sep 02 '23 at 21:14
  • Where you went wrong is asking ChatGPT for source code. – Pepijn Kramer Sep 03 '23 at 04:14
  • Good sources to learn cpp from are : A [recent C++ book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) or have a go at https://www.learncpp.com/ (that's pretty decent, and pretty up-to-date). For C++ reference material use : [cppreference](https://en.cppreference.com/w/). And after you learned the C++ basics from those sources, look at the [C++ coreguidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) regularely to keep up-to-date with the latest guidelines. – Pepijn Kramer Sep 03 '23 at 04:14

0 Answers0