2 * SHLWAPI registry functions
8 #include "wine/undocshell.h"
9 #include "debugtools.h"
11 DEFAULT_DEBUG_CHANNEL(shell);
13 /*************************************************************************
14 * SHRegGetUSValueA [SHLWAPI.@]
16 * Gets a user-specific registry value
18 LONG WINAPI SHRegGetUSValueA(
26 DWORD wDefaultDataSize)
28 FIXME("(%p),stub!\n", pSubKey);
29 return ERROR_SUCCESS; /* return success */
32 /*************************************************************************
33 * SHRegGetUSValueW [SHLWAPI.@]
35 * Gets a user-specific registry value
37 LONG WINAPI SHRegGetUSValueW(
45 DWORD wDefaultDataSize)
47 FIXME("(%p),stub!\n", pSubKey);
48 return ERROR_SUCCESS; /* return success */
51 /*************************************************************************
52 * SHRegGetBoolUSValueA [SHLWAPI.@]
54 BOOL WINAPI SHRegGetBoolUSValueA(
60 FIXME("%s %s\n", pszSubKey,pszValue);
64 /*************************************************************************
65 * SHRegGetBoolUSValueW [SHLWAPI.@]
67 BOOL WINAPI SHRegGetBoolUSValueW(
73 FIXME("%s %s\n", debugstr_w(pszSubKey),debugstr_w(pszValue));
77 /*************************************************************************
78 * SHRegQueryUSValueA [SHLWAPI]
80 LONG WINAPI SHRegQueryUSValueA(
81 HKEY hUSKey, /* [in] FIXME: HUSKEY */
88 DWORD dwDefaultDataSize)
90 FIXME("%s stub\n",pszValue);
94 /*************************************************************************
95 * SHRegGetPathA [SHLWAPI.@]
97 DWORD WINAPI SHRegGetPathA(
104 FIXME("%s %s\n", pcszSubKey, pcszValue);
108 /*************************************************************************
109 * SHRegGetPathW [SHLWAPI.@]
111 DWORD WINAPI SHRegGetPathW(
118 FIXME("%s %s\n", debugstr_w(pcszSubKey), debugstr_w(pcszValue));
122 /*************************************************************************
123 * SHGetValueA [SHLWAPI.@]
125 * Gets a value from the registry
127 DWORD WINAPI SHGetValueA(
138 TRACE("(%s %s)\n", pSubKey, pValue);
140 if((res = RegOpenKeyA(hkey, pSubKey, &hSubKey))) return res;
141 res = RegQueryValueExA(hSubKey, pValue, 0, pwType, pvData, pbData);
142 RegCloseKey( hSubKey );
147 /*************************************************************************
148 * SHGetValueW [SHLWAPI.@]
150 * Gets a value from the registry
152 DWORD WINAPI SHGetValueW(
163 TRACE("(%s %s)\n", debugstr_w(pSubKey), debugstr_w(pValue));
165 if((res = RegOpenKeyW(hkey, pSubKey, &hSubKey))) return res;
166 res = RegQueryValueExW(hSubKey, pValue, 0, pwType, pvData, pbData);
167 RegCloseKey( hSubKey );
172 /*************************************************************************
173 * SHSetValueA [SHLWAPI.@]
175 HRESULT WINAPI SHSetValueA(
186 hres = RegCreateKeyA(hkey,pszSubKey,&subkey);
189 hres = RegSetValueExA(subkey,pszValue,0,dwType,pvData,cbData);
194 /*************************************************************************
195 * SHSetValueW [SHLWAPI.@]
197 HRESULT WINAPI SHSetValueW(
208 hres = RegCreateKeyW(hkey,pszSubKey,&subkey);
211 hres = RegSetValueExW(subkey,pszValue,0,dwType,pvData,cbData);
216 /*************************************************************************
217 * SHQueryValueExA [SHLWAPI.@]
220 HRESULT WINAPI SHQueryValueExA(
228 TRACE("0x%04x %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
229 return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
233 /*************************************************************************
234 * SHQueryValueExW [SHLWAPI.@]
237 * if the datatype REG_EXPAND_SZ then expand the string and change
238 * *pdwType to REG_SZ.
240 HRESULT WINAPI SHQueryValueExW (
248 WARN("0x%04x %s %p %p %p %p semi-stub\n",
249 hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
250 return RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
253 /*************************************************************************
254 * SHDeleteKeyA [SHLWAPI.@]
256 * It appears this function is made available to account for the differences
257 * between the Win9x and WinNT/2k RegDeleteKeyA functions.
259 * According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
260 * WinNt/2k will only delete the key if empty.
262 HRESULT WINAPI SHDeleteKeyA(
266 DWORD r, dwKeyCount, dwSize, i, dwMaxSubkeyLen;
270 TRACE("hkey=0x%08x, %s\n", hKey, debugstr_a(lpszSubKey));
273 r = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
274 if(r != ERROR_SUCCESS)
277 /* find how many subkeys there are */
280 r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
281 &dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
282 if(r != ERROR_SUCCESS)
284 RegCloseKey(hSubKey);
288 /* alloc memory for the longest string terminating 0 */
290 lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen*sizeof(CHAR));
293 RegCloseKey(hSubKey);
294 return ERROR_NOT_ENOUGH_MEMORY;
297 /* recursively delete all the subkeys */
298 for(i=0; i<dwKeyCount; i++)
300 dwSize = dwMaxSubkeyLen;
301 r = RegEnumKeyExA(hSubKey, i, lpszName, &dwSize, NULL, NULL, NULL, NULL);
302 if(r != ERROR_SUCCESS)
304 r = SHDeleteKeyA(hSubKey, lpszName);
305 if(r != ERROR_SUCCESS)
309 HeapFree(GetProcessHeap(), 0, lpszName);
311 RegCloseKey(hSubKey);
313 if(r == ERROR_SUCCESS)
314 r = RegDeleteKeyA(hKey, lpszSubKey);
319 /*************************************************************************
320 * SHDeleteKeyW [SHLWAPI.@]
322 * It appears this function is made available to account for the differences
323 * between the Win9x and WinNT/2k RegDeleteKeyA functions.
325 * According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
326 * WinNt/2k will only delete the key if empty.
328 HRESULT WINAPI SHDeleteKeyW(
332 FIXME("hkey=0x%08x, %s\n", hkey, debugstr_w(pszSubKey));
336 /*************************************************************************
337 * SHDeleteValueA [SHLWAPI.@]
339 * Function opens the key, get/set/delete the value, then close the key.
341 HRESULT WINAPI SHDeleteValueA(HKEY hkey, LPCSTR pszSubKey, LPCSTR pszValue) {
345 hres = RegOpenKeyA(hkey,pszSubKey,&subkey);
348 hres = RegDeleteValueA(subkey,pszValue);
353 /*************************************************************************
354 * SHDeleteValueW [SHLWAPI.@]
356 * Function opens the key, get/set/delete the value, then close the key.
358 HRESULT WINAPI SHDeleteValueW(HKEY hkey, LPCWSTR pszSubKey, LPCWSTR pszValue) {
362 hres = RegOpenKeyW(hkey,pszSubKey,&subkey);
365 hres = RegDeleteValueW(subkey,pszValue);
370 /*************************************************************************
371 * SHDeleteEmptyKeyA [SHLWAPI.@]
373 * It appears this function is made available to account for the differences
374 * between the Win9x and WinNT/2k RegDeleteKeyA functions.
376 * According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
377 * WinNt/2k will only delete the key if empty.
379 DWORD WINAPI SHDeleteEmptyKeyA(HKEY hKey, LPCSTR lpszSubKey)
384 TRACE("hkey=0x%08x, %s\n", hKey, debugstr_a(lpszSubKey));
387 r = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
388 if(r != ERROR_SUCCESS)
392 r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
393 NULL, NULL, NULL, NULL, NULL, NULL, NULL);
394 if(r != ERROR_SUCCESS)
397 RegCloseKey(hSubKey);
400 return ERROR_KEY_HAS_CHILDREN;
402 r = RegDeleteKeyA(hKey, lpszSubKey);
407 /*************************************************************************
408 * SHDeleteEmptyKeyW [SHLWAPI.@]
410 * It appears this function is made available to account for the differences
411 * between the Win9x and WinNT/2k RegDeleteKeyA functions.
413 * According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
414 * WinNt/2k will only delete the key if empty.
416 DWORD WINAPI SHDeleteEmptyKeyW(HKEY hKey, LPCWSTR lpszSubKey)
418 FIXME("hkey=0x%08x, %s\n", hKey, debugstr_w(lpszSubKey));