Setting a Registry Key

Posted on 2000-05-16
Last Modified: 2013-11-20
   My App uses some API's that require a certain registry key to be set.
So as part of the initilisation of my app, I need to check if such a key exists and if not to create it.

So how do I go abt doing that?

Reading the key and then possible setting the appropriate key

Is there any MFC, Win32 command to do so ?

Thanks and Regards


Question by:manx

Expert Comment

ID: 2813894
If it is a part of API, not of your program, it is better to use Win 32 functions, e.g. RegQueryValueEx. There are some wrappers for this functions on 

Expert Comment

ID: 2814151
Duplicated question
LVL 10

Expert Comment

ID: 2815355
Or you can use the CRegKey ATL classes which already provide wrappers.
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.


Expert Comment

ID: 2817926
Heres a list of registry apis you can use:-

RegCreateKeyEx Creates the specified registry key.
RegDeleteKey Deletes a subkey.
RegDeleteValue Removes a named value from the specified registry key.
RegEnumKeyEx Enumerates subkeys of the specified open registry key.
RegEnumValue Enumerates the values for the specified open registry key.
RegLoadKey Creates a subkey under HKEY_USERS or HKEY_LOCAL_MACHINE and stores registration information from a specified file into that subkey.
RegOpenCurrentUser Retrieves a handle to the HKEY_CURRENT_USER key for the user the current thread is impersonating.
RegOpenKeyEx Opens the specified registry key.
RegOpenUserClassesRoot Retrieves a handle to the HKEY_CLASSES_ROOT key for the specified user.
RegQueryInfoKey Retrieves information about the specified registry key.
RegQueryMultipleValues Retrieves the type and data for a list of value names associated with an open registry key.
RegQueryValueEx Retrieves the type and data for a specified value name associated with an open registry key.
RegReplaceKey Replaces the file backing a registry key and all its subkeys with another file.
RegSetValueEx Sets the data and type of a specified value under a registry key.
RegUnLoadKey Unloads the specified registry key and its subkeys from the registry.

Expert Comment

ID: 2818363
iDeb changed the proposed answer to a comment
LVL 10

Accepted Solution

RONSLOW earned 50 total points
ID: 2819414
Here is my answer (as requested in the duplicate question).

Author Comment

ID: 2821597

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tripleUp challenge 7 86
changeXy challenge 13 87
wordmultiple challenge 12 140
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 818
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

789 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