Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Creating, Setting and Retrieving Registry Entries in C++

Posted on 1998-12-02
4
Medium Priority
?
393 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 400 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

782 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