1 /***********************************************************************\ 2 * winreg.d * 3 * * 4 * Windows API header module * 5 * * 6 * Translated from MinGW Windows headers * 7 * by Stewart Gordon * 8 * * 9 * Placed into public domain * 10 \***********************************************************************/ 11 module windows.winreg; 12 pragma(lib, "advapi32"); 13 14 private import windows.w32api, windows.winbase, windows.windef; 15 nothrow: 16 enum : HKEY { // for some reason, DMD errors if I don't give all the values explicitly 17 HKEY_CLASSES_ROOT = cast(HKEY) 0x80000000, 18 HKEY_CURRENT_USER = cast(HKEY) 0x80000001, 19 HKEY_LOCAL_MACHINE = cast(HKEY) 0x80000002, 20 HKEY_USERS = cast(HKEY) 0x80000003, 21 HKEY_PERFORMANCE_DATA = cast(HKEY) 0x80000004, 22 HKEY_CURRENT_CONFIG = cast(HKEY) 0x80000005, 23 HKEY_DYN_DATA = cast(HKEY) 0x80000006 24 } 25 26 enum : DWORD { 27 REG_OPTION_NON_VOLATILE, 28 REG_OPTION_VOLATILE 29 } 30 31 enum : DWORD { 32 REG_CREATED_NEW_KEY = 1, 33 REG_OPENED_EXISTING_KEY 34 } 35 36 enum : DWORD { 37 REG_NONE = 0, 38 REG_SZ, 39 REG_EXPAND_SZ, 40 REG_BINARY, 41 REG_DWORD_LITTLE_ENDIAN, 42 REG_DWORD = REG_DWORD_LITTLE_ENDIAN, 43 REG_DWORD_BIG_ENDIAN, 44 REG_LINK, 45 REG_MULTI_SZ, 46 REG_RESOURCE_LIST, 47 REG_FULL_RESOURCE_DESCRIPTOR, 48 REG_RESOURCE_REQUIREMENTS_LIST, 49 REG_QWORD_LITTLE_ENDIAN, 50 REG_QWORD = REG_QWORD_LITTLE_ENDIAN 51 } 52 53 const DWORD 54 REG_NOTIFY_CHANGE_NAME = 1, 55 REG_NOTIFY_CHANGE_ATTRIBUTES = 2, 56 REG_NOTIFY_CHANGE_LAST_SET = 4, 57 REG_NOTIFY_CHANGE_SECURITY = 8; 58 59 alias ACCESS_MASK REGSAM; 60 61 struct VALENTA { 62 LPSTR ve_valuename; 63 DWORD ve_valuelen; 64 DWORD ve_valueptr; 65 DWORD ve_type; 66 } 67 alias VALENTA* PVALENTA; 68 69 struct VALENTW { 70 LPWSTR ve_valuename; 71 DWORD ve_valuelen; 72 DWORD ve_valueptr; 73 DWORD ve_type; 74 } 75 alias VALENTW* PVALENTW; 76 77 // RRF - Registry Routine Flags (for RegGetValue) 78 static if (_WIN32_WINNT >= 0x600) { 79 enum : DWORD { 80 RRF_RT_REG_NONE = 0x00000001, 81 RRF_RT_REG_SZ = 0x00000002, 82 RRF_RT_REG_EXPAND_SZ = 0x00000004, 83 RRF_RT_REG_BINARY = 0x00000008, 84 RRF_RT_REG_DWORD = 0x00000010, 85 RRF_RT_REG_MULTI_SZ = 0x00000020, 86 RRF_RT_REG_QWORD = 0x00000040, 87 RRF_RT_DWORD = RRF_RT_REG_BINARY | RRF_RT_REG_DWORD, 88 RRF_RT_QWORD = RRF_RT_REG_BINARY | RRF_RT_REG_QWORD, 89 RRF_RT_ANY = 0x0000FFFF, 90 RRF_NOEXPAND = 0x10000000, 91 RRF_ZEROONFAILURE = 0x20000000 92 } 93 } 94 95 extern (Windows) { 96 LONG RegCloseKey(HKEY); 97 LONG RegConnectRegistryA(LPCSTR, HKEY, PHKEY); 98 LONG RegConnectRegistryW(LPCWSTR, HKEY, PHKEY); 99 LONG RegCreateKeyExA(HKEY, LPCSTR, DWORD, LPSTR, DWORD, REGSAM, 100 LPSECURITY_ATTRIBUTES, PHKEY, PDWORD); 101 LONG RegCreateKeyExW(HKEY, LPCWSTR, DWORD, LPWSTR, DWORD, REGSAM, 102 LPSECURITY_ATTRIBUTES, PHKEY, PDWORD); 103 LONG RegDeleteKeyA(HKEY, LPCSTR); 104 LONG RegDeleteKeyW(HKEY, LPCWSTR); 105 LONG RegDeleteValueA(HKEY, LPCSTR); 106 LONG RegDeleteValueW(HKEY, LPCWSTR); 107 LONG RegEnumKeyExA(HKEY, DWORD, LPSTR, PDWORD, PDWORD, LPSTR, PDWORD, 108 PFILETIME); 109 LONG RegEnumKeyExW(HKEY, DWORD, LPWSTR, PDWORD, PDWORD, LPWSTR, PDWORD, 110 PFILETIME); 111 LONG RegEnumValueA(HKEY, DWORD, LPSTR, PDWORD, PDWORD, PDWORD, LPBYTE, 112 PDWORD); 113 LONG RegEnumValueW(HKEY, DWORD, LPWSTR, PDWORD, PDWORD, PDWORD, LPBYTE, 114 PDWORD); 115 LONG RegFlushKey(HKEY); 116 LONG RegLoadKeyA(HKEY, LPCSTR, LPCSTR); 117 LONG RegLoadKeyW(HKEY, LPCWSTR, LPCWSTR); 118 LONG RegOpenKeyExA(HKEY, LPCSTR, DWORD, REGSAM, PHKEY); 119 LONG RegOpenKeyExW(HKEY, LPCWSTR, DWORD, REGSAM, PHKEY); 120 LONG RegQueryInfoKeyA(HKEY, LPSTR, PDWORD, PDWORD, PDWORD, PDWORD, 121 PDWORD, PDWORD, PDWORD, PDWORD, PDWORD, PFILETIME); 122 LONG RegQueryInfoKeyW(HKEY, LPWSTR, PDWORD, PDWORD, PDWORD, PDWORD, 123 PDWORD, PDWORD, PDWORD, PDWORD, PDWORD, PFILETIME); 124 LONG RegQueryMultipleValuesA(HKEY, PVALENTA, DWORD, LPSTR, LPDWORD); 125 LONG RegQueryMultipleValuesW(HKEY, PVALENTW, DWORD, LPWSTR, LPDWORD); 126 LONG RegQueryValueExA(HKEY, LPCSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD); 127 LONG RegQueryValueExW(HKEY, LPCWSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD); 128 LONG RegReplaceKeyA(HKEY, LPCSTR, LPCSTR, LPCSTR); 129 LONG RegReplaceKeyW(HKEY, LPCWSTR, LPCWSTR, LPCWSTR); 130 LONG RegSaveKeyA(HKEY, LPCSTR, LPSECURITY_ATTRIBUTES); 131 LONG RegSaveKeyW(HKEY, LPCWSTR, LPSECURITY_ATTRIBUTES); 132 LONG RegSetKeySecurity(HKEY, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR); 133 LONG RegSetValueExA(HKEY, LPCSTR, DWORD, DWORD, const(BYTE)*, DWORD); 134 LONG RegSetValueExW(HKEY, LPCWSTR, DWORD, DWORD, const(BYTE)*, DWORD); 135 LONG RegUnLoadKeyA(HKEY, LPCSTR); 136 LONG RegUnLoadKeyW(HKEY, LPCWSTR); 137 LONG RegNotifyChangeKeyValue(HKEY, BOOL, DWORD, HANDLE, BOOL); 138 139 BOOL AbortSystemShutdownA(LPCSTR); 140 BOOL AbortSystemShutdownW(LPCWSTR); 141 BOOL InitiateSystemShutdownA(LPSTR, LPSTR, DWORD, BOOL, BOOL); 142 BOOL InitiateSystemShutdownW(LPWSTR, LPWSTR, DWORD, BOOL, BOOL); 143 LONG RegGetKeySecurity(HKEY, SECURITY_INFORMATION, 144 PSECURITY_DESCRIPTOR, PDWORD); 145 LONG RegRestoreKeyA(HKEY, LPCSTR, DWORD); 146 LONG RegRestoreKeyW(HKEY, LPCWSTR, DWORD); 147 LONG RegSetKeySecurity(HKEY, SECURITY_INFORMATION, 148 PSECURITY_DESCRIPTOR); 149 150 static if (_WIN32_WINNT >= 0x500) { 151 LONG RegDisablePredefinedCache(); 152 LONG RegOpenCurrentUser(REGSAM, PHKEY); 153 LONG RegOpenUserClassesRoot(HANDLE, DWORD, REGSAM, PHKEY); 154 } 155 156 static if (_WIN32_WINNT >= 0x501) { 157 LONG RegSaveKeyExA(HKEY, LPCSTR, LPSECURITY_ATTRIBUTES, DWORD); 158 LONG RegSaveKeyExW(HKEY, LPCWSTR, LPSECURITY_ATTRIBUTES, DWORD); 159 } 160 161 static if (_WIN32_WINNT >= 0x600) { 162 LONG RegGetValueA(HKEY hkey, LPCSTR lpSubKey, LPCSTR lpValue, 163 DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData); 164 LONG RegGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, 165 DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData); 166 } 167 168 deprecated { 169 LONG RegCreateKeyA(HKEY, LPCSTR, PHKEY); 170 LONG RegCreateKeyW(HKEY, LPCWSTR, PHKEY); 171 LONG RegEnumKeyA(HKEY, DWORD, LPSTR, DWORD); 172 LONG RegEnumKeyW(HKEY, DWORD, LPWSTR, DWORD); 173 LONG RegOpenKeyA(HKEY, LPCSTR, PHKEY); 174 LONG RegOpenKeyW(HKEY, LPCWSTR, PHKEY); 175 LONG RegQueryValueA(HKEY, LPCSTR, LPSTR, PLONG); 176 LONG RegQueryValueW(HKEY, LPCWSTR, LPWSTR, PLONG); 177 LONG RegSetValueA(HKEY, LPCSTR, DWORD, LPCSTR, DWORD); 178 LONG RegSetValueW(HKEY, LPCWSTR, DWORD, LPCWSTR, DWORD); 179 } 180 } 181 182 version (Unicode) { 183 alias VALENTW VALENT; 184 alias RegConnectRegistryW RegConnectRegistry; 185 alias RegCreateKeyExW RegCreateKeyEx; 186 alias RegDeleteKeyW RegDeleteKey; 187 alias RegDeleteValueW RegDeleteValue; 188 alias RegEnumKeyExW RegEnumKeyEx; 189 alias RegEnumValueW RegEnumValue; 190 alias RegLoadKeyW RegLoadKey; 191 alias RegOpenKeyExW RegOpenKeyEx; 192 alias RegQueryInfoKeyW RegQueryInfoKey; 193 alias RegQueryMultipleValuesW RegQueryMultipleValues; 194 alias RegQueryValueExW RegQueryValueEx; 195 alias RegReplaceKeyW RegReplaceKey; 196 alias RegSaveKeyW RegSaveKey; 197 alias RegSetValueExW RegSetValueEx; 198 alias RegUnLoadKeyW RegUnLoadKey; 199 200 alias AbortSystemShutdownW AbortSystemShutdown; 201 alias InitiateSystemShutdownW InitiateSystemShutdown; 202 alias RegRestoreKeyW RegRestoreKey; 203 static if (_WIN32_WINNT >= 0x501) { 204 alias RegSaveKeyExA RegSaveKeyEx; 205 } 206 static if (_WIN32_WINNT >= 0x600) { 207 alias RegGetValueW RegGetValue; 208 } 209 deprecated { 210 alias RegCreateKeyW RegCreateKey; 211 alias RegEnumKeyW RegEnumKey; 212 alias RegOpenKeyW RegOpenKey; 213 alias RegQueryValueW RegQueryValue; 214 alias RegSetValueW RegSetValue; 215 } 216 } else { 217 alias VALENTA VALENT; 218 alias RegConnectRegistryA RegConnectRegistry; 219 alias RegCreateKeyExA RegCreateKeyEx; 220 alias RegDeleteKeyA RegDeleteKey; 221 alias RegDeleteValueA RegDeleteValue; 222 alias RegEnumKeyExA RegEnumKeyEx; 223 alias RegEnumValueA RegEnumValue; 224 alias RegLoadKeyA RegLoadKey; 225 alias RegOpenKeyExA RegOpenKeyEx; 226 alias RegQueryInfoKeyA RegQueryInfoKey; 227 alias RegQueryMultipleValuesA RegQueryMultipleValues; 228 alias RegQueryValueExA RegQueryValueEx; 229 alias RegReplaceKeyA RegReplaceKey; 230 alias RegSaveKeyA RegSaveKey; 231 alias RegSetValueExA RegSetValueEx; 232 alias RegUnLoadKeyA RegUnLoadKey; 233 alias AbortSystemShutdownA AbortSystemShutdown; 234 alias InitiateSystemShutdownA InitiateSystemShutdown; 235 alias RegRestoreKeyW RegRestoreKey; 236 static if (_WIN32_WINNT >= 0x501) { 237 alias RegSaveKeyExA RegSaveKeyEx; 238 } 239 static if (_WIN32_WINNT >= 0x600) { 240 alias RegGetValueA RegGetValue; 241 } 242 deprecated { 243 alias RegCreateKeyA RegCreateKey; 244 alias RegEnumKeyA RegEnumKey; 245 alias RegOpenKeyA RegOpenKey; 246 alias RegQueryValueA RegQueryValue; 247 alias RegSetValueA RegSetValue; 248 } 249 } 250 251 alias VALENT* PVALENT;