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*/ 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 DWORD WINAPI SHSetValueA(
183 FIXME("(%s %s)stub\n",pszSubKey, pszValue);
187 /*************************************************************************
188 * SHQueryValueExA [SHLWAPI.@]
191 HRESULT WINAPI SHQueryValueExA(
199 TRACE("0x%04x %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
200 return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
204 /*************************************************************************
205 * SHQueryValueExW [SHLWAPI.@]
208 * if the datatype REG_EXPAND_SZ then expand the string and change
209 * *pdwType to REG_SZ.
211 HRESULT WINAPI SHQueryValueExW (
219 WARN("0x%04x %s %p %p %p %p semi-stub\n",
220 hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
221 return RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
224 /*************************************************************************
225 * SHDeleteKeyA [SHLWAPI.@]
227 * It appears this function is made available to account for the differences
228 * between the Win9x and WinNT/2k RegDeleteKeyA functions.
230 * According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
231 * WinNt/2k will only delete the key if empty.
233 HRESULT WINAPI SHDeleteKeyA(
237 DWORD r, dwKeyCount, dwSize, i, dwMaxSubkeyLen;
241 TRACE("hkey=0x%08x, %s\n", hKey, debugstr_a(lpszSubKey));
244 r = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
245 if(r != ERROR_SUCCESS)
248 /* find how many subkeys there are */
251 r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
252 &dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
253 if(r != ERROR_SUCCESS)
255 RegCloseKey(hSubKey);
259 /* alloc memory for the longest string terminating 0 */
261 lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen*sizeof(CHAR));
264 RegCloseKey(hSubKey);
265 return ERROR_NOT_ENOUGH_MEMORY;
268 /* recursively delete all the subkeys */
269 for(i=0; i<dwKeyCount; i++)
271 dwSize = dwMaxSubkeyLen;
272 r = RegEnumKeyExA(hSubKey, i, lpszName, &dwSize, NULL, NULL, NULL, NULL);
273 if(r != ERROR_SUCCESS)
275 r = SHDeleteKeyA(hSubKey, lpszName);
276 if(r != ERROR_SUCCESS)
280 HeapFree(GetProcessHeap(), 0, lpszName);
282 RegCloseKey(hSubKey);
284 if(r == ERROR_SUCCESS)
285 r = RegDeleteKeyA(hKey, lpszSubKey);
290 /*************************************************************************
291 * SHDeleteKeyW [SHLWAPI.@]
293 * It appears this function is made available to account for the differences
294 * between the Win9x and WinNT/2k RegDeleteKeyA functions.
296 * According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
297 * WinNt/2k will only delete the key if empty.
299 HRESULT WINAPI SHDeleteKeyW(
303 FIXME("hkey=0x%08x, %s\n", hkey, debugstr_w(pszSubKey));
307 /*************************************************************************
308 * SHDeleteEmptyKeyA [SHLWAPI.@]
310 * It appears this function is made available to account for the differences
311 * between the Win9x and WinNT/2k RegDeleteKeyA functions.
313 * According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
314 * WinNt/2k will only delete the key if empty.
316 DWORD WINAPI SHDeleteEmptyKeyA(HKEY hKey, LPCSTR lpszSubKey)
321 TRACE("hkey=0x%08x, %s\n", hKey, debugstr_a(lpszSubKey));
324 r = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
325 if(r != ERROR_SUCCESS)
329 r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
330 NULL, NULL, NULL, NULL, NULL, NULL, NULL);
331 if(r != ERROR_SUCCESS)
334 RegCloseKey(hSubKey);
337 return ERROR_KEY_HAS_CHILDREN;
339 r = RegDeleteKeyA(hKey, lpszSubKey);
344 /*************************************************************************
345 * SHDeleteEmptyKeyW [SHLWAPI.@]
347 * It appears this function is made available to account for the differences
348 * between the Win9x and WinNT/2k RegDeleteKeyA functions.
350 * According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
351 * WinNt/2k will only delete the key if empty.
353 DWORD WINAPI SHDeleteEmptyKeyW(HKEY hKey, LPCWSTR lpszSubKey)
355 FIXME("hkey=0x%08x, %s\n", hKey, debugstr_w(lpszSubKey));