Click here to Skip to main content
15,896,912 members
Articles / Programming Languages / C++

A handy class to make use of Windows Registry

Rate me:
Please Sign up or sign in to vote.
3.81/5 (18 votes)
15 Aug 20043 min read 89.2K   1.9K   28  
Shows how simple accessing Windows Registry can be if you do not need bells and whistles.
#include "registry.h"
#include <iostream>

class my_app{
protected:
	registry reg;
	registry::iterator UserName;
public:
	my_app():reg("Software\\Company"),UserName(reg["UserName"]){}
	~my_app(){}
	void SetUserName(const char * name){
		UserName = name;
	}
	const char * GetUserName(){
		return (const char *) UserName;
	}
};

int main (int, char *){
	my_app App;
	App.SetUserName("Alex");
	std::cout<<"The username is: "<<App.GetUserName()<<"\nThanks for playing..."<<std::endl;
	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Canada Canada
Big Grin | :-D

Comments and Discussions