SamGoody
SamGoody

Reputation: 14528

C++ registry handling without .NET

For a script that will check/set a Windows registry value. No GUI.
Am writing in Visual Studio, but do not want .NET - just C++.

However, I haven't figured out where and what methods exist natively in C++ [NOT Visual C++] that interface with the registry.
I also haven't worked out how to compile C++ code in Visual Studio 2010 without .NET.

Can someone please direct me to the documentation (or even better, tutorials) of the standard C++ registry related methods.
And furnish me with instructions or point out a tutorial that will allow a complete and total noob to compile in VS a non .NET program.

Please do NOT argue about my aversion to .NET, that has been the subject of other threads.

Upvotes: 0

Views: 1136

Answers (5)

Mac
Mac

Reputation: 14791

Windows Registry Functions

Generally the flow goes something like:

  1. Open the registry key with RegOpenKeyEx. The last parameter is a pointer to a registry key handle for the opened key (if the open is successful).
  2. Using the returned registry key, you can set its value using RegSetValueEx, you can add new subkeys using RegCreateKeyEx, and delete keys using RegDeleteKey.
  3. Close any opened or created keys using RegCloseKey.

There is a tutorial to be found here.

Unfortunately I don't use VS, so I'm not the person to help you with compiling "vanilla" C++ in that. That said though, I imagine it shouldn't be all that difficult - there's probably an option somewhere for a "Plain C++" project.

Upvotes: 2

Pablo
Pablo

Reputation: 8644

You can also use Stlsoft's registry components for an STL-like interface.

Upvotes: 0

Kyle Alons
Kyle Alons

Reputation: 7135

To create a native C++ console application in VS 2010: http://msdn.microsoft.com/en-us/library/46e82t5z.aspx

To check/set registry values using Win32 APIs: http://msdn.microsoft.com/en-us/library/ms724875%28v=VS.85%29.aspx

Upvotes: 1

Adam Rosenfield
Adam Rosenfield

Reputation: 400700

Here's a list of all of the native functions for interacting with the registry. The most useful ones are probably RegOpenKeyEx, RegQueryValueEx, RegSetValueEx, and RegCloseKey.

A number of good articles describing usage of the registry can be found here.

Upvotes: 2

Related Questions