开发者

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.


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.


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.


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


You can use mfc. This shows how http://www.endurasoft.com/techtalk/regdemo1.htm

or atl http://msdn.microsoft.com/en-us/library/xka57xy4(v=vs.71).aspx


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜