Solved

Creating, Setting and Retrieving Registry Entries in C++

Posted on 1998-12-02
4
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

752 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