Hi all!!
I am trying to save the subkeys and values of a key in a text file and i am not getting the result. the file created has not a recognizable name and there is nothing stored in it.. so please help me in this....thanx
here is the code:
// recent.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "recent.h"
#include<conio.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
		nRetCode = 1;
	}
	else
	{
		HKEY hTestKey;
		if(RegOpenKeyEx( HKEY_CURRENT_USER,TEXT("SOFTWARE\\Microsoft\\Internet Explorer\\Settings"),0,KEY_READ,&hTestKey) == ERROR_SUCCESS )
		{ cout<<"Into the registry"; getch();}
		 LPCTSTR name=(LPCTSTR)"mydata.txt";
   if(RegSaveKey(hTestKey,name,NULL))
	   cout<<"file loaded"; 
   getch();


	}

	return nRetCode;
}

line 32: you can't typecast ascii to unicode. should be something like this: LPCTSTR name= _TEXT("mydata.txt");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.