Solved

Creating, Setting and Retrieving Registry Entries in C++

Posted on 1998-12-02
4
363 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

758 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

20 Experts available now in Live!

Get 1:1 Help Now