Solved

Creating, Setting and Retrieving Registry Entries in C++

Posted on 1998-12-02
4
368 Views
Last Modified: 2008-01-09
Hi Experts,

Currently, whenever I develop some application, I creat an .INI file for that application to read required settings. I want to save these setting in Windows' Registry from where my application will read them. Therefore I am looking for some expert to give me a small example for achieving this task. I am using VC++ 5.0.

Thanks,
Mohsin
0
Comment
Question by:Mohsin
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 100 total points
ID: 1179117
Check the following functions:

SetRegistryKey
WriteProfileInt
WriteProfileInt
GetProfileString
GetProfileString

All of them are CWinApp class members.

If you have any more questions just ask, I'll do my best.

0
 

Author Comment

by:Mohsin
ID: 1179118
Hi,

I tried SetRegistryKey()before but the compiler gives me an error message. Here is what I tried in one of the functions of the application:
AfxGetApp()->SetRegistryKey("HKEY_CURRENT_USER\\Software\\World-link\\Watchdog");

The compiler's error message is:
error C2248: 'SetRegistryKey' : cannot access protected member declared in class 'CWinApp'

Please advise what to do?

Thanks.
Mohsin




0
 
LVL 3

Expert Comment

by:plaroche
ID: 1179119
SetRegistryKey has to be called from the class itself or one of its derivatives. Do this call in you CWinApp::OnInitInstance:

SetRegistryKey("HKEY_CURRENT_USER\\Software\\World-link\\Watchdog");

You do know what a protected function in C++ is?
0
 

Author Comment

by:Mohsin
ID: 1179120
Thanks
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now