Solved

Creating, Setting and Retrieving Registry Entries in C++

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

636 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