uLib  User mode C/C++ extended API library for Win32 programmers.
RegFunc.h
Go to the documentation of this file.
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 // Project: uLib - User mode utility library.
3 // Module: Additional registry functions.
4 // Author: Copyright (c) Love Nystrom
5 // License: NNOSL (BSD descendant, see NNOSL.txt in the base directory).
6 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 
8 #ifndef _RegCls_h_incl_
9 #define _RegCls_h_incl_
10 
11 #include <uLib/Common.h>
12 #include <uLib/Debug.h>
13 #include <uLib/UtilFunc.h>
14 #include <uLib/StrFunc.h>
15 
17 
22 
23 #define KEY_CONTROL (DELETE| READ_CONTROL| WRITE_DAC| WRITE_OWNER) //|SYNCHRONIZE
24 #ifndef KEY_RW
25 #define KEY_RW (KEY_READ|KEY_WRITE)
26 #endif
27 
28 #ifndef ALL_SECURITY_INFO
29 #define ALL_SECURITY_INFO \
30  ( OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION \
31  | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION )
32 #endif
33 
34 #define REG_OK(rc) (rc == NOERROR)
35 #define REG_ERR(rc) (rc != NOERROR)
36 
37 //-----------------------------------------------------------------------------
38 // New registry API's
39 //-----------------------------------------------------------------------------
40 
44 
45 HKEY RegCloseKeyEx( HKEY Key );
46 
50 
51 BOOL RegKeyExist( HKEY BaseKey, CSTR RegPath );
52 
56 
57 BOOL RegValueExist( HKEY hKey, CSTR Name );
58 
61 
62 #define RegQueryDefaultValue( hKey, pType, pData, pSize ) \
63  RegQueryValueEx( hKey, _T(""), 0, pType, pData, pSize )
64 
70 
71 #define RegQuerySubkeys( hKey, pNrKeys, pCcKeyname ) \
72  RegQueryInfoKey( hKey, 0,0,0, pNrKeys, pCcKeyname, 0,0,0,0,0,0 )
73 
78 
79 LONG RegDeleteBranch( HKEY Parent, CSTR SubkeyName );
80 
101 
102 LONG _RegRenameKey( HKEY BaseKey, CSTR Subkey, CSTR NewSubkeyName );
103 
105 
106 LONG RegRenameValue( HKEY hKey, CSTR OldName, CSTR NewName );
107 
110 
111 CSTR RegSysKeyName( HKEY hkey );
112 CSTR RegSysKeyAcronym( HKEY hkey );
113 CSTR RegTypeName( DWORD type );
114 
117 
118 CSTR RegValueName( CSTR name );
119 
120 //-----------------------------------------------------------------------------
121 // Simple reg value wrappers to make application code less tedious...
122 //-----------------------------------------------------------------------------
123 
124 // REG_DWORD
125 
126 LONG RegSetDWord( HKEY hKey, CSTR ValName, DWORD Val );
127 LONG RegGetDWord( HKEY hKey, CSTR ValName, PDWORD pVal );
128 LONG RegGetUInt( HKEY hKey, CSTR ValName, PUINT pVal );
129 LONG RegGetBool( HKEY hKey, CSTR ValName, bool* pVal );
130 // TODO...
131 //LONG RegSetQWord( HKEY hKey, CSTR ValName, QWORD Val );
132 //LONG RegGetQWord( HKEY hKey, CSTR ValName, PQWORD pVal );
133 //LONG RegSetDouble( HKEY hKey, CSTR ValName, double Val );
134 //LONG RegGetDouble( HKEY hKey, CSTR ValName, double* pVal );
135 
136 // REG_BINARY
137 
138 LONG RegSetBinary( HKEY hKey, CSTR ValName, PBYTE Val, DWORD Size );
139 LONG RegGetBinary( HKEY hKey, CSTR ValName, PBYTE pVal, PDWORD pSize );
140 
141 // REG_SZ
142 
143 LONG RegSetString( HKEY hKey, CSTR ValName, CSTR Str, DWORD Type );
144 LONG RegGetString( HKEY hKey, CSTR ValName, TSTR Buf, PDWORD Size, PDWORD Type );
145 
148 
149 LONG SaveWindowRect( HWND hWnd, HKEY baseKey, CSTR regPath, CSTR valName );
150 LONG RestoreWindowRect( HWND hWnd, HKEY baseKey, CSTR regPath, CSTR valName );
152 
155 //-----------------------------------------------------------------------------
156 #endif //ndef _RegCls_h_incl_
157 // EOF
unsigned long DWORD
Definition: Common.h:414
LONG RegSetString(HKEY hKey, CSTR ValName, CSTR Str, DWORD Type)
Definition: RegFunc.cpp:144
LONG RestoreWindowRect(HWND hWnd, HKEY baseKey, CSTR regPath, CSTR valName)
Definition: RegFunc.cpp:184
#define CSTR
Definition: Common.h:329
HKEY RegCloseKeyEx(HKEY Key)
Definition: RegFunc.cpp:22
CSTR RegValueName(CSTR name)
Definition: RegFunc.cpp:516
LONG RegGetDWord(HKEY hKey, CSTR ValName, PDWORD pVal)
Definition: RegFunc.cpp:100
LONG RegGetBool(HKEY hKey, CSTR ValName, bool *pVal)
Definition: RegFunc.cpp:116
#define TSTR
Definition: Common.h:328
unsigned char * PBYTE
Definition: Common.h:412
BOOL RegKeyExist(HKEY BaseKey, CSTR RegPath)
Definition: RegFunc.cpp:35
LONG RegGetString(HKEY hKey, CSTR ValName, TSTR Buf, PDWORD Size, PDWORD Type)
Definition: RegFunc.cpp:151
LONG RegGetUInt(HKEY hKey, CSTR ValName, PUINT pVal)
Definition: RegFunc.cpp:111
BOOL(WINAPI *SysImgList::Shell_GetImageLists)(HIMAGELIST *pimlLarge
CSTR RegSysKeyName(HKEY hkey)
Definition: RegFunc.cpp:440
LONG _RegRenameKey(HKEY BaseKey, CSTR Subkey, CSTR NewSubkeyName)
Definition: RegFunc.cpp:301
CSTR RegSysKeyAcronym(HKEY hkey)
Definition: RegFunc.cpp:467
LONG RegSetBinary(HKEY hKey, CSTR ValName, PBYTE Val, DWORD Size)
Definition: RegFunc.cpp:126
LONG RegDeleteBranch(HKEY Parent, CSTR SubkeyName)
Definition: RegFunc.cpp:213
Debug and error handling support.
Common include; Added types, small "ubiquitous" utilities, et c.
#define END_EXTERN_C
Definition: Common.h:221
#define BEGIN_EXTERN_C
Definition: Common.h:220
LONG RegGetBinary(HKEY hKey, CSTR ValName, PBYTE pVal, PDWORD pSize)
Definition: RegFunc.cpp:131
BOOL RegValueExist(HKEY hKey, CSTR Name)
Definition: RegFunc.cpp:46
LONG SaveWindowRect(HWND hWnd, HKEY baseKey, CSTR regPath, CSTR valName)
Definition: RegFunc.cpp:167
LONG RegRenameValue(HKEY hKey, CSTR OldName, CSTR NewName)
Definition: RegFunc.cpp:71
LONG RegSetDWord(HKEY hKey, CSTR ValName, DWORD Val)
Definition: RegFunc.cpp:95
CSTR RegTypeName(DWORD type)
Definition: RegFunc.cpp:493
unsigned long * PDWORD
Definition: Common.h:414