Welcome to mirror list, hosted at ThFree Co, Russian Federation.

win_registry.c « src - github.com/windirstat/lua-winreg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a6ff9722ba3beef322f3e41f8fbfb2355658ea04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <windows.h>

// delete the whole sub key
LONG win_reg_deltree(HKEY hParentKey, const TCHAR * strKeyName){
	TCHAR   szSubKeyName[MAX_PATH];
	HKEY    hCurrentKey;
	LONG   dwResult;
	if ((dwResult = RegOpenKey(hParentKey, strKeyName, &hCurrentKey)) == ERROR_SUCCESS){
		// Remove all subkeys of the key to delete
		while ((dwResult = RegEnumKey(hCurrentKey, 0, szSubKeyName, 255)) == ERROR_SUCCESS){
			if((dwResult = win_reg_deltree(hCurrentKey, szSubKeyName)) != ERROR_SUCCESS)break;
		}
		// If all went well, we should now be able to delete the requested key
		if((dwResult == ERROR_NO_MORE_ITEMS) || (dwResult == ERROR_BADKEY)){
			dwResult = RegDeleteKey(hParentKey, strKeyName);
		}
		RegCloseKey(hCurrentKey);
	}
	return dwResult;
}