Click here to Skip to main content
15,899,754 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralClipboard API calls Pin
impeham11-Jan-04 23:54
impeham11-Jan-04 23:54 
GeneralRe: Clipboard API calls Pin
pratheesh12-Jan-04 1:14
pratheesh12-Jan-04 1:14 
GeneralRe: Clipboard API calls Pin
impeham12-Jan-04 2:19
impeham12-Jan-04 2:19 
GeneralRe: Clipboard API calls Pin
pratheesh12-Jan-04 18:24
pratheesh12-Jan-04 18:24 
GeneralRe: Clipboard API calls Pin
impeham12-Jan-04 23:48
impeham12-Jan-04 23:48 
GeneralRe: Clipboard API calls Pin
pratheesh13-Jan-04 23:23
pratheesh13-Jan-04 23:23 
GeneralRe: Clipboard API calls Pin
David Crow12-Jan-04 5:13
David Crow12-Jan-04 5:13 
GeneralProblem with Wh_getmessage Hook Pin
percyvimal11-Jan-04 23:52
percyvimal11-Jan-04 23:52 
GeneralSend message from separate Thread Pin
Cedric Moonen11-Jan-04 23:18
Cedric Moonen11-Jan-04 23:18 
GeneralRe: Send message from separate Thread Pin
Roger Allen11-Jan-04 23:51
Roger Allen11-Jan-04 23:51 
GeneralRe: Send message from separate Thread Pin
Cedric Moonen11-Jan-04 23:57
Cedric Moonen11-Jan-04 23:57 
GeneralRe: Send message from separate Thread Pin
Cedric Moonen12-Jan-04 2:56
Cedric Moonen12-Jan-04 2:56 
GeneralRe: Send message from separate Thread Pin
KarstenK12-Jan-04 4:21
mveKarstenK12-Jan-04 4:21 
GeneralRe: Send message from separate Thread Pin
Cedric Moonen12-Jan-04 4:37
Cedric Moonen12-Jan-04 4:37 
GeneralSaving information in registry 'HKEY_LOCAL_MACHINE' Pin
JensB11-Jan-04 23:14
JensB11-Jan-04 23:14 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
Roger Allen11-Jan-04 23:54
Roger Allen11-Jan-04 23:54 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
Jijo.Raj12-Jan-04 0:07
Jijo.Raj12-Jan-04 0:07 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
JensB12-Jan-04 0:13
JensB12-Jan-04 0:13 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
Jijo.Raj12-Jan-04 1:38
Jijo.Raj12-Jan-04 1:38 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
JensB12-Jan-04 2:09
JensB12-Jan-04 2:09 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
Jijo.Raj12-Jan-04 2:13
Jijo.Raj12-Jan-04 2:13 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
JensB12-Jan-04 4:47
JensB12-Jan-04 4:47 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
Jijo.Raj12-Jan-04 5:46
Jijo.Raj12-Jan-04 5:46 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
Anonymous12-Jan-04 20:11
Anonymous12-Jan-04 20:11 
GeneralRe: Saving information in registry 'HKEY_LOCAL_MACHINE' Pin
Jijo.Raj13-Jan-04 2:26
Jijo.Raj13-Jan-04 2:26 
hai Jens,
Use the following code. I got it from my friend - John AV, who is a registry expert. Big Grin | :-D Okey. First be thorough with the code, make any changes if you need, then use it.

const static int nMaxValueNameSize = MAX_PATH;
const static int nMaxValueValueSize = 4096;
const static int nMaxClassSize = MAX_PATH;
const static int nMaxKeyNameSize = MAX_PATH;

BOOL CopyRegistryKey(HKEY hkRootFrom, const CString& strFromPath, HKEY hkRootTo, const CString& strToPath) 
{
	HKEY hkFrom;
	LONG res = ::RegOpenKeyEx(hkRootFrom, strFromPath, 0, KEY_READ, &hkFrom);
	if (ERROR_SUCCESS != res) {
		return FALSE;	
	}
	HKEY hkTo;
	res = ::RegCreateKeyEx(hkRootTo, strToPath, 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hkTo, 0);
	if (ERROR_SUCCESS != res) {
		::RegCloseKey(hkFrom);
		return FALSE;	
	}
	BOOL bRes = CopyKeys(hkFrom, hkTo) && CopyValues(hkFrom, hkTo);

	::RegCloseKey(hkFrom);
	::RegCloseKey(hkTo);

	return bRes;
}

static BOOL CopyKeys(HKEY hkFrom, HKEY hkTo) 
{
	TCHAR lpstrName[nMaxKeyNameSize];
	TCHAR lpstrClass[nMaxClassSize];

	for (int i = 0;;i++) {
		DWORD nNameSize = nMaxKeyNameSize;
		DWORD nClassSize = nMaxClassSize;
		LONG res = ::RegEnumKeyEx(hkFrom, i, lpstrName, &nNameSize, 0, lpstrClass, &nClassSize, 0);
		if (ERROR_NO_MORE_ITEMS == res) {
			break;
		}
		HKEY hkNew;
		res = ::RegCreateKeyEx(hkTo, lpstrName, 0, lpstrClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hkNew, 0); ;
		if (ERROR_SUCCESS != res) {
			return FALSE;		
		}
		::RegCloseKey(hkNew);
		BOOL bRes = CopyRegistryKey(hkFrom, lpstrName, hkTo, lpstrName);
		if (! bRes) {
			return FALSE;		
		}
	}

	return TRUE;
}

static BOOL CopyValues(HKEY hkFrom, HKEY hkTo) 
{
	TCHAR lpstrName[nMaxValueNameSize];
	BYTE pValue[nMaxValueValueSize];

	for (int i = 0;;i++) {
		DWORD nType;
		DWORD nNameSize = nMaxValueNameSize;
		DWORD nValueSize = nMaxValueValueSize;
		LONG res = ::RegEnumValue(hkFrom, i, lpstrName, &nNameSize, 0, &nType, pValue, &nValueSize);
		if (ERROR_NO_MORE_ITEMS == res) {
			break;
		}
		res = ::RegSetValueEx(hkTo, lpstrName, 0, nType, pValue, nValueSize);
		if (ERROR_SUCCESS != res) {
			return FALSE;		
		}
	}

	return TRUE;
}


Hope this helped you.

Regards,
Jijo. Wink | ;)

________________________________

Yesterday is history,
Tomorrow is a mystery,
But today is a present.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.