I want to create a key in the Registry Editor of Windows XP using c++ program.
After this i am to write the Name and the Data(e.g value) of that particular key using c++ program.
And i am to read the Name and Data(Value) of that particular key using c++ program.

Please help me regarding this issue.
I am doing it of my own....

i am trying my self to create KEY in Registry Editor through c++ program but when i run my program, "not successfully create key"..
i am using REGCreate(...) but still key is not creating,

Plz if u have any idea, describe with me in your own words...

Here is an example of how to create a key. Make sure you read the Remarks section of this link

#include <Windows.h>
#include <iostream>
using std::cout;

int main(int argc, char* argv[])
	HKEY hKey = 0;
	DWORD dwDisposition = 0;
	long retval = RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Ancient Dragon",0,0,REG_OPTION_NON_VOLATILE,
	if( retval !=  ERROR_SUCCESS)
		char buf[255] = {0};
		DWORD dwError = GetLastError();
		cout << buf << '\n';
		cout << dwDisposition << '\n';
	return 0;

yes!!!! its working successFully....
Thanks dear,
Now i have done Create Key, setvalue, and reading Value from key....

Again Thanks.....

Problem to increment key value
now i want to increment key value at run-time, i am trying but nothing solved this problem yet.
e.g. when i run program the key-value is 1, and i want that when i run this program again the key-value should be 2...

plz help me for this problem

Simple solution -- each time the program starts it updates the key value with a new value. Call RegQueryValue() to get the current value, increment the counter, then RegSetKeyValue() to update it.

Call these functions in the order listed. You will have to do error checking to insure they succeed.

Edited 5 Years Ago by Ancient Dragon: n/a

Thanx for reply,
But i solve this problem myself before your reply...
And i also solve my problem through RgOpenKeyEx() as u said....

But Thanx for reply because your posts are useful for me & others...

This question has already been answered. Start a new discussion instead.