2000-07-26 17:51:32 +00:00
|
|
|
/*
|
|
|
|
* SHLWAPI registry functions
|
|
|
|
*/
|
|
|
|
|
2001-03-22 19:33:57 +00:00
|
|
|
#include <string.h>
|
2000-07-26 17:51:32 +00:00
|
|
|
#include "windef.h"
|
2001-02-13 20:17:59 +00:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2000-07-26 17:51:32 +00:00
|
|
|
#include "winerror.h"
|
2001-10-21 15:09:36 +00:00
|
|
|
#include "winnls.h"
|
2000-07-26 17:51:32 +00:00
|
|
|
#include "winreg.h"
|
|
|
|
#include "debugtools.h"
|
2001-01-07 21:50:52 +00:00
|
|
|
#include "shlwapi.h"
|
2001-02-13 20:17:59 +00:00
|
|
|
#include "wine/unicode.h"
|
2000-07-26 17:51:32 +00:00
|
|
|
|
|
|
|
DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
2001-02-13 20:17:59 +00:00
|
|
|
static const char *lpszContentTypeA = "Content Type";
|
|
|
|
static const WCHAR lpszContentTypeW[] = { 'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
|
|
|
|
|
2001-10-21 15:09:36 +00:00
|
|
|
/* internal structure of what the HUSKEY points to */
|
|
|
|
typedef struct {
|
2001-10-24 02:45:08 +00:00
|
|
|
HKEY HKCUkey; /* HKEY of opened HKCU key */
|
|
|
|
HKEY HKLMkey; /* HKEY of opened HKLM key */
|
|
|
|
HKEY start; /* HKEY of where to start */
|
2001-10-21 15:09:36 +00:00
|
|
|
WCHAR key_string[MAX_PATH]; /* additional path from 'start' */
|
|
|
|
} Internal_HUSKEY, *LPInternal_HUSKEY;
|
|
|
|
|
|
|
|
|
2001-10-24 02:45:08 +00:00
|
|
|
#define REG_HKCU TRUE
|
|
|
|
#define REG_HKLM FALSE
|
|
|
|
/*************************************************************************
|
|
|
|
* REG_GetHKEYFromHUSKEY
|
|
|
|
*
|
|
|
|
* Function: Return the proper registry key from the HUSKEY structure
|
|
|
|
* also allow special predefined values.
|
|
|
|
*/
|
|
|
|
HKEY REG_GetHKEYFromHUSKEY(HUSKEY hUSKey, BOOL which)
|
|
|
|
{
|
|
|
|
HKEY test = (HKEY) hUSKey;
|
|
|
|
LPInternal_HUSKEY mihk = (LPInternal_HUSKEY) hUSKey;
|
|
|
|
|
|
|
|
if ((test == HKEY_CLASSES_ROOT) ||
|
|
|
|
(test == HKEY_CURRENT_CONFIG) ||
|
|
|
|
(test == HKEY_CURRENT_USER) ||
|
|
|
|
(test == HKEY_DYN_DATA) ||
|
|
|
|
(test == HKEY_LOCAL_MACHINE) ||
|
|
|
|
(test == HKEY_PERFORMANCE_DATA) ||
|
|
|
|
/* FIXME: need to define for Win2k, ME, XP
|
|
|
|
* (test == HKEY_PERFORMANCE_TEXT) ||
|
|
|
|
* (test == HKEY_PERFORMANCE_NLSTEXT) ||
|
|
|
|
*/
|
|
|
|
(test == HKEY_USERS)) return test;
|
|
|
|
if (which == REG_HKCU) return mihk->HKCUkey;
|
|
|
|
return mihk->HKLMkey;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-21 15:09:36 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHRegOpenUSKeyA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Opens a user-specific registry key
|
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegOpenUSKeyA(
|
|
|
|
LPCSTR Path,
|
|
|
|
REGSAM AccessType,
|
|
|
|
HUSKEY hRelativeUSKey,
|
|
|
|
PHUSKEY phNewUSKey,
|
|
|
|
BOOL fIgnoreHKCU)
|
|
|
|
{
|
2001-10-24 02:45:08 +00:00
|
|
|
HKEY openHKCUkey=0;
|
|
|
|
HKEY openHKLMkey=0;
|
|
|
|
LONG ret2, ret1 = ~ERROR_SUCCESS;
|
2001-10-21 15:09:36 +00:00
|
|
|
LPInternal_HUSKEY ihky;
|
|
|
|
|
|
|
|
TRACE("(%s, 0x%lx, 0x%lx, %p, %s)\n", debugstr_a(Path),
|
|
|
|
(LONG)AccessType, (LONG)hRelativeUSKey, phNewUSKey,
|
|
|
|
(fIgnoreHKCU) ? "Ignoring HKCU" : "Process HKCU then HKLM");
|
2001-10-24 02:45:08 +00:00
|
|
|
|
|
|
|
/* now create the internal version of HUSKEY */
|
|
|
|
ihky = (LPInternal_HUSKEY)HeapAlloc(GetProcessHeap(), 0 ,
|
|
|
|
sizeof(Internal_HUSKEY));
|
|
|
|
MultiByteToWideChar(0, 0, Path, -1, ihky->key_string,
|
|
|
|
sizeof(ihky->key_string)-1);
|
|
|
|
|
|
|
|
if (hRelativeUSKey) {
|
|
|
|
openHKCUkey = ((LPInternal_HUSKEY)hRelativeUSKey)->HKCUkey;
|
|
|
|
openHKLMkey = ((LPInternal_HUSKEY)hRelativeUSKey)->HKLMkey;
|
|
|
|
}
|
2001-10-21 15:09:36 +00:00
|
|
|
else {
|
2001-10-24 02:45:08 +00:00
|
|
|
openHKCUkey = HKEY_CURRENT_USER;
|
|
|
|
openHKLMkey = HKEY_LOCAL_MACHINE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ihky->HKCUkey = 0;
|
|
|
|
ihky->HKLMkey = 0;
|
|
|
|
if (!fIgnoreHKCU) {
|
|
|
|
ret1 = RegOpenKeyExA(HKEY_CURRENT_USER, Path,
|
|
|
|
0, AccessType, &ihky->HKCUkey);
|
|
|
|
/* if successful, then save real starting point */
|
|
|
|
if (ret1 != ERROR_SUCCESS)
|
|
|
|
ihky->HKCUkey = 0;
|
2001-10-21 15:09:36 +00:00
|
|
|
}
|
2001-10-24 02:45:08 +00:00
|
|
|
ret2 = RegOpenKeyExA(HKEY_LOCAL_MACHINE, Path,
|
|
|
|
0, AccessType, &ihky->HKLMkey);
|
|
|
|
if (ret2 != ERROR_SUCCESS)
|
|
|
|
ihky->HKLMkey = 0;
|
2001-10-21 15:09:36 +00:00
|
|
|
|
2001-10-24 02:45:08 +00:00
|
|
|
if ((ret1 != ERROR_SUCCESS) || (ret2 != ERROR_SUCCESS))
|
|
|
|
TRACE("one or more opens failed: HKCU=%ld HKLM=%ld\n", ret1, ret2);
|
2001-10-21 15:09:36 +00:00
|
|
|
|
|
|
|
/* if all attempts have failed then bail */
|
2001-10-24 02:45:08 +00:00
|
|
|
if ((ret1 != ERROR_SUCCESS) && (ret2 != ERROR_SUCCESS)) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, ihky);
|
|
|
|
if (phNewUSKey)
|
|
|
|
*phNewUSKey = (HUSKEY)0;
|
|
|
|
return ret2;
|
2001-10-21 15:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("HUSKEY=0x%08lx\n", (LONG)ihky);
|
|
|
|
if (phNewUSKey)
|
|
|
|
*phNewUSKey = (HUSKEY)ihky;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegOpenUSKeyW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Opens a user-specific registry key
|
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegOpenUSKeyW(
|
|
|
|
LPCWSTR Path,
|
|
|
|
REGSAM AccessType,
|
|
|
|
HUSKEY hRelativeUSKey,
|
|
|
|
PHUSKEY phNewUSKey,
|
|
|
|
BOOL fIgnoreHKCU)
|
|
|
|
{
|
2001-10-24 02:45:08 +00:00
|
|
|
HKEY openHKCUkey=0;
|
|
|
|
HKEY openHKLMkey=0;
|
|
|
|
LONG ret2, ret1 = ~ERROR_SUCCESS;
|
2001-10-21 15:09:36 +00:00
|
|
|
LPInternal_HUSKEY ihky;
|
|
|
|
|
|
|
|
TRACE("(%s, 0x%lx, 0x%lx, %p, %s)\n", debugstr_w(Path),
|
|
|
|
(LONG)AccessType, (LONG)hRelativeUSKey, phNewUSKey,
|
|
|
|
(fIgnoreHKCU) ? "Ignoring HKCU" : "Process HKCU then HKLM");
|
2001-10-24 02:45:08 +00:00
|
|
|
|
|
|
|
/* now create the internal version of HUSKEY */
|
|
|
|
ihky = (LPInternal_HUSKEY)HeapAlloc(GetProcessHeap(), 0 ,
|
|
|
|
sizeof(Internal_HUSKEY));
|
|
|
|
lstrcpynW(ihky->key_string, Path, sizeof(ihky->key_string));
|
|
|
|
|
|
|
|
if (hRelativeUSKey) {
|
|
|
|
openHKCUkey = ((LPInternal_HUSKEY)hRelativeUSKey)->HKCUkey;
|
|
|
|
openHKLMkey = ((LPInternal_HUSKEY)hRelativeUSKey)->HKLMkey;
|
|
|
|
}
|
2001-10-21 15:09:36 +00:00
|
|
|
else {
|
2001-10-24 02:45:08 +00:00
|
|
|
openHKCUkey = HKEY_CURRENT_USER;
|
|
|
|
openHKLMkey = HKEY_LOCAL_MACHINE;
|
2001-10-21 15:09:36 +00:00
|
|
|
}
|
|
|
|
|
2001-10-24 02:45:08 +00:00
|
|
|
ihky->HKCUkey = 0;
|
|
|
|
ihky->HKLMkey = 0;
|
|
|
|
if (!fIgnoreHKCU) {
|
|
|
|
ret1 = RegOpenKeyExW(HKEY_CURRENT_USER, Path,
|
|
|
|
0, AccessType, &ihky->HKCUkey);
|
|
|
|
/* if successful, then save real starting point */
|
|
|
|
if (ret1 != ERROR_SUCCESS)
|
|
|
|
ihky->HKCUkey = 0;
|
|
|
|
}
|
|
|
|
ret2 = RegOpenKeyExW(HKEY_LOCAL_MACHINE, Path,
|
|
|
|
0, AccessType, &ihky->HKLMkey);
|
|
|
|
if (ret2 != ERROR_SUCCESS)
|
|
|
|
ihky->HKLMkey = 0;
|
|
|
|
|
|
|
|
if ((ret1 != ERROR_SUCCESS) || (ret2 != ERROR_SUCCESS))
|
|
|
|
TRACE("one or more opens failed: HKCU=%ld HKLM=%ld\n", ret1, ret2);
|
2001-10-21 15:09:36 +00:00
|
|
|
|
|
|
|
/* if all attempts have failed then bail */
|
2001-10-24 02:45:08 +00:00
|
|
|
if ((ret1 != ERROR_SUCCESS) && (ret2 != ERROR_SUCCESS)) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, ihky);
|
|
|
|
if (phNewUSKey)
|
|
|
|
*phNewUSKey = (HUSKEY)0;
|
|
|
|
return ret2;
|
2001-10-21 15:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("HUSKEY=0x%08lx\n", (LONG)ihky);
|
|
|
|
if (phNewUSKey)
|
|
|
|
*phNewUSKey = (HUSKEY)ihky;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegCloseUSKey [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Closes a user-specific registry key
|
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegCloseUSKey(
|
|
|
|
HUSKEY hUSKey)
|
|
|
|
{
|
|
|
|
LPInternal_HUSKEY mihk = (LPInternal_HUSKEY)hUSKey;
|
2001-10-24 02:45:08 +00:00
|
|
|
LONG ret = ERROR_SUCCESS;
|
2001-10-21 15:09:36 +00:00
|
|
|
|
2001-10-24 02:45:08 +00:00
|
|
|
if (mihk->HKCUkey)
|
|
|
|
ret = RegCloseKey(mihk->HKCUkey);
|
|
|
|
if (mihk->HKLMkey)
|
|
|
|
ret = RegCloseKey(mihk->HKLMkey);
|
2001-10-21 15:09:36 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, mihk);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-10-24 02:45:08 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHRegQueryUSValueA [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegQueryUSValueA(
|
|
|
|
HUSKEY hUSKey, /* [in] */
|
|
|
|
LPCSTR pszValue,
|
|
|
|
LPDWORD pdwType,
|
|
|
|
LPVOID pvData,
|
|
|
|
LPDWORD pcbData,
|
|
|
|
BOOL fIgnoreHKCU,
|
|
|
|
LPVOID pvDefaultData,
|
|
|
|
DWORD dwDefaultDataSize)
|
|
|
|
{
|
|
|
|
LONG ret = ~ERROR_SUCCESS;
|
|
|
|
LONG i, maxmove;
|
|
|
|
HKEY dokey;
|
|
|
|
CHAR *src, *dst;
|
|
|
|
|
|
|
|
/* if user wants HKCU, and it exists, then try it */
|
|
|
|
if (!fIgnoreHKCU && (dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU)))
|
|
|
|
ret = RegQueryValueExA(dokey,
|
|
|
|
pszValue, 0, pdwType, pvData, pcbData);
|
|
|
|
|
|
|
|
/* if HKCU did not work and HKLM exists, then try it */
|
|
|
|
if ((ret != ERROR_SUCCESS) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU)))
|
|
|
|
ret = RegQueryValueExA(dokey,
|
|
|
|
pszValue, 0, pdwType, pvData, pcbData);
|
|
|
|
|
|
|
|
/* if neither worked, and default data exists, then use it */
|
|
|
|
if (ret != ERROR_SUCCESS) {
|
|
|
|
if (pvDefaultData && (dwDefaultDataSize != 0)) {
|
|
|
|
maxmove = (dwDefaultDataSize >= *pcbData) ? *pcbData : dwDefaultDataSize;
|
|
|
|
src = (CHAR*)pvDefaultData;
|
|
|
|
dst = (CHAR*)pvData;
|
|
|
|
for(i=0; i<maxmove; i++) *dst++ = *src++;
|
|
|
|
*pcbData = maxmove;
|
|
|
|
TRACE("setting default data\n");
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegQueryUSValueW [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegQueryUSValueW(
|
|
|
|
HUSKEY hUSKey, /* [in] */
|
|
|
|
LPCWSTR pszValue,
|
|
|
|
LPDWORD pdwType,
|
|
|
|
LPVOID pvData,
|
|
|
|
LPDWORD pcbData,
|
|
|
|
BOOL fIgnoreHKCU,
|
|
|
|
LPVOID pvDefaultData,
|
|
|
|
DWORD dwDefaultDataSize)
|
|
|
|
{
|
|
|
|
LONG ret = ~ERROR_SUCCESS;
|
|
|
|
LONG i, maxmove;
|
|
|
|
HKEY dokey;
|
|
|
|
CHAR *src, *dst;
|
|
|
|
|
|
|
|
/* if user wants HKCU, and it exists, then try it */
|
|
|
|
if (!fIgnoreHKCU && (dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU)))
|
|
|
|
ret = RegQueryValueExW(dokey,
|
|
|
|
pszValue, 0, pdwType, pvData, pcbData);
|
|
|
|
|
|
|
|
/* if HKCU did not work and HKLM exists, then try it */
|
|
|
|
if ((ret != ERROR_SUCCESS) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU)))
|
|
|
|
ret = RegQueryValueExW(dokey,
|
|
|
|
pszValue, 0, pdwType, pvData, pcbData);
|
|
|
|
|
|
|
|
/* if neither worked, and default data exists, then use it */
|
|
|
|
if (ret != ERROR_SUCCESS) {
|
|
|
|
if (pvDefaultData && (dwDefaultDataSize != 0)) {
|
|
|
|
maxmove = (dwDefaultDataSize >= *pcbData) ? *pcbData : dwDefaultDataSize;
|
|
|
|
src = (CHAR*)pvDefaultData;
|
|
|
|
dst = (CHAR*)pvData;
|
|
|
|
for(i=0; i<maxmove; i++) *dst++ = *src++;
|
|
|
|
*pcbData = maxmove;
|
|
|
|
TRACE("setting default data\n");
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHRegGetUSValueA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Gets a user-specific registry value
|
2001-10-24 02:45:08 +00:00
|
|
|
* Will open the key, query the value, and close the key
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegGetUSValueA(
|
|
|
|
LPCSTR pSubKey,
|
|
|
|
LPCSTR pValue,
|
|
|
|
LPDWORD pwType,
|
|
|
|
LPVOID pvData,
|
2001-10-21 15:09:36 +00:00
|
|
|
LPDWORD pcbData,
|
|
|
|
BOOL flagIgnoreHKCU,
|
2000-07-26 17:51:32 +00:00
|
|
|
LPVOID pDefaultData,
|
|
|
|
DWORD wDefaultDataSize)
|
|
|
|
{
|
2001-10-21 15:09:36 +00:00
|
|
|
HUSKEY myhuskey;
|
2001-10-24 02:45:08 +00:00
|
|
|
LONG ret;
|
2001-10-21 15:09:36 +00:00
|
|
|
|
|
|
|
if (!pvData || !pcbData) return ERROR_INVALID_FUNCTION; /* FIXME:wrong*/
|
|
|
|
TRACE("key '%s', value '%s', datalen %ld, %s\n",
|
|
|
|
debugstr_a(pSubKey), debugstr_a(pValue), *pcbData,
|
2001-11-06 21:01:32 +00:00
|
|
|
(flagIgnoreHKCU) ? "Ignoring HKCU" : "Tries HKCU then HKLM");
|
2001-10-21 15:09:36 +00:00
|
|
|
|
|
|
|
ret = SHRegOpenUSKeyA(pSubKey, 0x1, 0, &myhuskey, flagIgnoreHKCU);
|
|
|
|
if (ret == ERROR_SUCCESS) {
|
2001-10-24 02:45:08 +00:00
|
|
|
ret = SHRegQueryUSValueA(myhuskey, pValue, pwType, pvData,
|
|
|
|
pcbData, flagIgnoreHKCU, pDefaultData,
|
|
|
|
wDefaultDataSize);
|
2001-10-21 15:09:36 +00:00
|
|
|
SHRegCloseUSKey(myhuskey);
|
|
|
|
}
|
|
|
|
return ret;
|
2000-07-26 17:51:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegGetUSValueW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Gets a user-specific registry value
|
2001-10-24 02:45:08 +00:00
|
|
|
* Will open the key, query the value, and close the key
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegGetUSValueW(
|
|
|
|
LPCWSTR pSubKey,
|
|
|
|
LPCWSTR pValue,
|
|
|
|
LPDWORD pwType,
|
|
|
|
LPVOID pvData,
|
2001-10-21 15:09:36 +00:00
|
|
|
LPDWORD pcbData,
|
2000-07-26 17:51:32 +00:00
|
|
|
BOOL flagIgnoreHKCU,
|
|
|
|
LPVOID pDefaultData,
|
|
|
|
DWORD wDefaultDataSize)
|
|
|
|
{
|
2001-10-21 15:09:36 +00:00
|
|
|
HUSKEY myhuskey;
|
2001-10-24 02:45:08 +00:00
|
|
|
LONG ret;
|
2000-07-26 17:51:32 +00:00
|
|
|
|
2001-10-21 15:09:36 +00:00
|
|
|
if (!pvData || !pcbData) return ERROR_INVALID_FUNCTION; /* FIXME:wrong*/
|
|
|
|
TRACE("key '%s', value '%s', datalen %ld, %s\n",
|
|
|
|
debugstr_w(pSubKey), debugstr_w(pValue), *pcbData,
|
2001-11-06 21:01:32 +00:00
|
|
|
(flagIgnoreHKCU) ? "Ignoring HKCU" : "Tries HKCU then HKLM");
|
2001-04-25 19:51:56 +00:00
|
|
|
|
2001-10-21 15:09:36 +00:00
|
|
|
ret = SHRegOpenUSKeyW(pSubKey, 0x1, 0, &myhuskey, flagIgnoreHKCU);
|
|
|
|
if (ret == ERROR_SUCCESS) {
|
2001-10-24 02:45:08 +00:00
|
|
|
ret = SHRegQueryUSValueW(myhuskey, pValue, pwType, pvData,
|
|
|
|
pcbData, flagIgnoreHKCU, pDefaultData,
|
|
|
|
wDefaultDataSize);
|
2001-10-21 15:09:36 +00:00
|
|
|
SHRegCloseUSKey(myhuskey);
|
|
|
|
}
|
|
|
|
return ret;
|
2001-04-25 19:51:56 +00:00
|
|
|
}
|
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHRegGetBoolUSValueA [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SHRegGetBoolUSValueA(
|
|
|
|
LPCSTR pszSubKey,
|
|
|
|
LPCSTR pszValue,
|
|
|
|
BOOL fIgnoreHKCU,
|
|
|
|
BOOL fDefault)
|
|
|
|
{
|
2001-10-28 21:13:16 +00:00
|
|
|
LONG retvalue;
|
|
|
|
DWORD type, datalen, work;
|
|
|
|
BOOL ret = fDefault;
|
|
|
|
CHAR data[10];
|
|
|
|
|
|
|
|
TRACE("key '%s', value '%s', %s\n",
|
|
|
|
debugstr_a(pszSubKey), debugstr_a(pszValue),
|
2001-11-06 21:01:32 +00:00
|
|
|
(fIgnoreHKCU) ? "Ignoring HKCU" : "Tries HKCU then HKLM");
|
2001-10-28 21:13:16 +00:00
|
|
|
|
|
|
|
datalen = sizeof(data)-1;
|
|
|
|
if (!(retvalue = SHRegGetUSValueA( pszSubKey, pszValue, &type,
|
|
|
|
data, &datalen,
|
|
|
|
fIgnoreHKCU, 0, 0))) {
|
|
|
|
/* process returned data via type into bool */
|
|
|
|
switch (type) {
|
|
|
|
case REG_SZ:
|
|
|
|
data[9] = '\0'; /* set end of string */
|
|
|
|
if (lstrcmpiA(data, "YES") == 0) ret = TRUE;
|
|
|
|
if (lstrcmpiA(data, "TRUE") == 0) ret = TRUE;
|
|
|
|
if (lstrcmpiA(data, "NO") == 0) ret = FALSE;
|
|
|
|
if (lstrcmpiA(data, "FALSE") == 0) ret = FALSE;
|
|
|
|
break;
|
|
|
|
case REG_DWORD:
|
|
|
|
work = *(LPDWORD)data;
|
|
|
|
ret = (work != 0);
|
|
|
|
break;
|
|
|
|
case REG_BINARY:
|
|
|
|
if (datalen == 1) {
|
|
|
|
ret = (data[0] != '\0');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported registry data type %ld\n", type);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
TRACE("got value (type=%ld), returing <%s>\n", type,
|
|
|
|
(ret) ? "TRUE" : "FALSE");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ret = fDefault;
|
|
|
|
TRACE("returning default data <%s>\n",
|
|
|
|
(ret) ? "TRUE" : "FALSE");
|
|
|
|
}
|
|
|
|
return ret;
|
2000-07-26 17:51:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegGetBoolUSValueW [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SHRegGetBoolUSValueW(
|
|
|
|
LPCWSTR pszSubKey,
|
|
|
|
LPCWSTR pszValue,
|
|
|
|
BOOL fIgnoreHKCU,
|
|
|
|
BOOL fDefault)
|
|
|
|
{
|
2001-11-06 00:48:51 +00:00
|
|
|
static const WCHAR wYES[]= {'Y','E','S','\0'};
|
|
|
|
static const WCHAR wTRUE[]= {'T','R','U','E','\0'};
|
|
|
|
static const WCHAR wNO[]= {'N','O','\0'};
|
|
|
|
static const WCHAR wFALSE[]={'F','A','L','S','E','\0'};
|
2001-10-28 21:13:16 +00:00
|
|
|
LONG retvalue;
|
|
|
|
DWORD type, datalen, work;
|
|
|
|
BOOL ret = fDefault;
|
|
|
|
WCHAR data[10];
|
|
|
|
|
|
|
|
TRACE("key '%s', value '%s', %s\n",
|
|
|
|
debugstr_w(pszSubKey), debugstr_w(pszValue),
|
2001-11-06 21:01:32 +00:00
|
|
|
(fIgnoreHKCU) ? "Ignoring HKCU" : "Tries HKCU then HKLM");
|
2001-10-28 21:13:16 +00:00
|
|
|
|
|
|
|
datalen = (sizeof(data)-1) * sizeof(WCHAR);
|
|
|
|
if (!(retvalue = SHRegGetUSValueW( pszSubKey, pszValue, &type,
|
|
|
|
data, &datalen,
|
|
|
|
fIgnoreHKCU, 0, 0))) {
|
|
|
|
/* process returned data via type into bool */
|
|
|
|
switch (type) {
|
|
|
|
case REG_SZ:
|
|
|
|
data[9] = L'\0'; /* set end of string */
|
2001-11-06 00:48:51 +00:00
|
|
|
if (lstrcmpiW(data, wYES)==0 || lstrcmpiW(data, wTRUE)==0)
|
|
|
|
ret = TRUE;
|
|
|
|
else if (lstrcmpiW(data, wNO)==0 || lstrcmpiW(data, wFALSE)==0)
|
|
|
|
ret = FALSE;
|
2001-10-28 21:13:16 +00:00
|
|
|
break;
|
|
|
|
case REG_DWORD:
|
|
|
|
work = *(LPDWORD)data;
|
|
|
|
ret = (work != 0);
|
|
|
|
break;
|
|
|
|
case REG_BINARY:
|
|
|
|
if (datalen == 1) {
|
|
|
|
ret = (data[0] != L'\0');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported registry data type %ld\n", type);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
TRACE("got value (type=%ld), returing <%s>\n", type,
|
|
|
|
(ret) ? "TRUE" : "FALSE");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ret = fDefault;
|
|
|
|
TRACE("returning default data <%s>\n",
|
|
|
|
(ret) ? "TRUE" : "FALSE");
|
|
|
|
}
|
|
|
|
return ret;
|
2000-07-26 17:51:32 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 15:09:36 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHRegQueryInfoUSKeyA [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHRegQueryInfoUSKeyA(
|
2001-10-24 02:45:08 +00:00
|
|
|
HUSKEY hUSKey, /* [in] */
|
2001-10-21 15:09:36 +00:00
|
|
|
LPDWORD pcSubKeys,
|
|
|
|
LPDWORD pcchMaxSubKeyLen,
|
|
|
|
LPDWORD pcValues,
|
|
|
|
LPDWORD pcchMaxValueNameLen,
|
|
|
|
SHREGENUM_FLAGS enumRegFlags)
|
|
|
|
{
|
2001-10-24 02:45:08 +00:00
|
|
|
HKEY dokey;
|
|
|
|
LONG ret;
|
|
|
|
|
2001-10-21 15:09:36 +00:00
|
|
|
TRACE("(0x%lx,%p,%p,%p,%p,%d)\n",
|
2001-10-24 02:45:08 +00:00
|
|
|
(LONG)hUSKey,pcSubKeys,pcchMaxSubKeyLen,pcValues,
|
|
|
|
pcchMaxValueNameLen,enumRegFlags);
|
|
|
|
|
|
|
|
/* if user wants HKCU, and it exists, then try it */
|
|
|
|
if (((enumRegFlags == SHREGENUM_HKCU) ||
|
|
|
|
(enumRegFlags == SHREGENUM_DEFAULT)) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU))) {
|
|
|
|
ret = RegQueryInfoKeyA(dokey, 0, 0, 0,
|
|
|
|
pcSubKeys, pcchMaxSubKeyLen, 0,
|
|
|
|
pcValues, pcchMaxValueNameLen, 0, 0, 0);
|
|
|
|
if ((ret == ERROR_SUCCESS) ||
|
|
|
|
(enumRegFlags == SHREGENUM_HKCU))
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (((enumRegFlags == SHREGENUM_HKLM) ||
|
|
|
|
(enumRegFlags == SHREGENUM_DEFAULT)) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKLM))) {
|
|
|
|
return RegQueryInfoKeyA(dokey, 0, 0, 0,
|
|
|
|
pcSubKeys, pcchMaxSubKeyLen, 0,
|
|
|
|
pcValues, pcchMaxValueNameLen, 0, 0, 0);
|
|
|
|
}
|
|
|
|
return ERROR_INVALID_FUNCTION;
|
2001-10-21 15:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegQueryInfoUSKeyW [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHRegQueryInfoUSKeyW(
|
2001-10-24 02:45:08 +00:00
|
|
|
HUSKEY hUSKey, /* [in] */
|
2001-10-21 15:09:36 +00:00
|
|
|
LPDWORD pcSubKeys,
|
|
|
|
LPDWORD pcchMaxSubKeyLen,
|
|
|
|
LPDWORD pcValues,
|
|
|
|
LPDWORD pcchMaxValueNameLen,
|
|
|
|
SHREGENUM_FLAGS enumRegFlags)
|
|
|
|
{
|
2001-10-24 02:45:08 +00:00
|
|
|
HKEY dokey;
|
|
|
|
LONG ret;
|
|
|
|
|
2001-10-21 15:09:36 +00:00
|
|
|
TRACE("(0x%lx,%p,%p,%p,%p,%d)\n",
|
|
|
|
(LONG)hUSKey,pcSubKeys,pcchMaxSubKeyLen,pcValues,
|
|
|
|
pcchMaxValueNameLen,enumRegFlags);
|
2001-10-24 02:45:08 +00:00
|
|
|
|
|
|
|
/* if user wants HKCU, and it exists, then try it */
|
|
|
|
if (((enumRegFlags == SHREGENUM_HKCU) ||
|
|
|
|
(enumRegFlags == SHREGENUM_DEFAULT)) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU))) {
|
|
|
|
ret = RegQueryInfoKeyW(dokey, 0, 0, 0,
|
|
|
|
pcSubKeys, pcchMaxSubKeyLen, 0,
|
|
|
|
pcValues, pcchMaxValueNameLen, 0, 0, 0);
|
|
|
|
if ((ret == ERROR_SUCCESS) ||
|
|
|
|
(enumRegFlags == SHREGENUM_HKCU))
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (((enumRegFlags == SHREGENUM_HKLM) ||
|
|
|
|
(enumRegFlags == SHREGENUM_DEFAULT)) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKLM))) {
|
|
|
|
return RegQueryInfoKeyW(dokey, 0, 0, 0,
|
|
|
|
pcSubKeys, pcchMaxSubKeyLen, 0,
|
|
|
|
pcValues, pcchMaxValueNameLen, 0, 0, 0);
|
|
|
|
}
|
|
|
|
return ERROR_INVALID_FUNCTION;
|
2001-10-21 15:09:36 +00:00
|
|
|
}
|
|
|
|
|
2001-09-07 18:36:47 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHRegEnumUSKeyA [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegEnumUSKeyA(
|
2001-10-21 15:09:36 +00:00
|
|
|
HUSKEY hUSKey, /* [in] */
|
2001-11-13 21:28:21 +00:00
|
|
|
DWORD dwIndex, /* [in] */
|
|
|
|
LPSTR pszName, /* [out] */
|
|
|
|
LPDWORD pcchValueNameLen, /* [in/out] */
|
2001-10-21 15:09:36 +00:00
|
|
|
SHREGENUM_FLAGS enumRegFlags) /* [in] */
|
2001-09-07 18:36:47 +00:00
|
|
|
{
|
2001-11-13 21:28:21 +00:00
|
|
|
HKEY dokey;
|
|
|
|
|
|
|
|
TRACE("(0x%lx,%ld,%p,%p(%ld),%d)\n",
|
|
|
|
(LONG)hUSKey, dwIndex, pszName, pcchValueNameLen,
|
|
|
|
*pcchValueNameLen, enumRegFlags);
|
|
|
|
|
|
|
|
if (((enumRegFlags == SHREGENUM_HKCU) ||
|
|
|
|
(enumRegFlags == SHREGENUM_DEFAULT)) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU))) {
|
|
|
|
return RegEnumKeyExA(dokey, dwIndex, pszName, pcchValueNameLen,
|
|
|
|
0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((enumRegFlags == SHREGENUM_HKLM) ||
|
|
|
|
(enumRegFlags == SHREGENUM_DEFAULT)) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKLM))) {
|
|
|
|
return RegEnumKeyExA(dokey, dwIndex, pszName, pcchValueNameLen,
|
|
|
|
0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
FIXME("no support for SHREGNUM_BOTH\n");
|
|
|
|
return ERROR_INVALID_FUNCTION;
|
2001-09-07 18:36:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegEnumUSKeyW [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegEnumUSKeyW(
|
2001-10-21 15:09:36 +00:00
|
|
|
HUSKEY hUSKey, /* [in] */
|
2001-11-13 21:28:21 +00:00
|
|
|
DWORD dwIndex, /* [in] */
|
|
|
|
LPWSTR pszName, /* [out] */
|
|
|
|
LPDWORD pcchValueNameLen, /* [in/out] */
|
2001-10-21 15:09:36 +00:00
|
|
|
SHREGENUM_FLAGS enumRegFlags) /* [in] */
|
2001-09-07 18:36:47 +00:00
|
|
|
{
|
2001-11-13 21:28:21 +00:00
|
|
|
HKEY dokey;
|
|
|
|
|
|
|
|
TRACE("(0x%lx,%ld,%p,%p(%ld),%d)\n",
|
|
|
|
(LONG)hUSKey, dwIndex, pszName, pcchValueNameLen,
|
|
|
|
*pcchValueNameLen, enumRegFlags);
|
|
|
|
|
|
|
|
if (((enumRegFlags == SHREGENUM_HKCU) ||
|
|
|
|
(enumRegFlags == SHREGENUM_DEFAULT)) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU))) {
|
|
|
|
return RegEnumKeyExW(dokey, dwIndex, pszName, pcchValueNameLen,
|
|
|
|
0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((enumRegFlags == SHREGENUM_HKLM) ||
|
|
|
|
(enumRegFlags == SHREGENUM_DEFAULT)) &&
|
|
|
|
(dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKLM))) {
|
|
|
|
return RegEnumKeyExW(dokey, dwIndex, pszName, pcchValueNameLen,
|
|
|
|
0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
FIXME("no support for SHREGNUM_BOTH\n");
|
|
|
|
return ERROR_INVALID_FUNCTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegWriteUSValueA [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegWriteUSValueA(HUSKEY hUSKey, LPCSTR pszValue, DWORD dwType,
|
|
|
|
LPVOID pvData, DWORD cbData, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(0x%lx,%s,%ld,%p,%ld,%ld): stub\n",
|
|
|
|
(LONG)hUSKey, debugstr_a(pszValue), dwType, pvData, cbData, dwFlags);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegWriteUSValueW [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
LONG WINAPI SHRegWriteUSValueW(HUSKEY hUSKey, LPCWSTR pszValue, DWORD dwType,
|
|
|
|
LPVOID pvData, DWORD cbData, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(0x%lx,%s,%ld,%p,%ld,%ld): stub\n",
|
|
|
|
(LONG)hUSKey, debugstr_w(pszValue), dwType, pvData, cbData, dwFlags);
|
|
|
|
return ERROR_SUCCESS;
|
2001-09-07 18:36:47 +00:00
|
|
|
}
|
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHRegGetPathA [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHRegGetPathA(
|
|
|
|
HKEY hKey,
|
|
|
|
LPCSTR pcszSubKey,
|
|
|
|
LPCSTR pcszValue,
|
|
|
|
LPSTR pszPath,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("%s %s\n", pcszSubKey, pcszValue);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegGetPathW [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHRegGetPathW(
|
|
|
|
HKEY hKey,
|
|
|
|
LPCWSTR pcszSubKey,
|
|
|
|
LPCWSTR pcszValue,
|
|
|
|
LPWSTR pszPath,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("%s %s\n", debugstr_w(pcszSubKey), debugstr_w(pcszValue));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHGetValueA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Gets a value from the registry
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHGetValueA(
|
|
|
|
HKEY hkey,
|
|
|
|
LPCSTR pSubKey,
|
|
|
|
LPCSTR pValue,
|
|
|
|
LPDWORD pwType,
|
|
|
|
LPVOID pvData,
|
|
|
|
LPDWORD pbData)
|
|
|
|
{
|
|
|
|
HKEY hSubKey;
|
|
|
|
DWORD res;
|
2001-02-13 20:17:59 +00:00
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
TRACE("(%s %s)\n", pSubKey, pValue);
|
2001-02-13 20:17:59 +00:00
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
if((res = RegOpenKeyA(hkey, pSubKey, &hSubKey))) return res;
|
|
|
|
res = RegQueryValueExA(hSubKey, pValue, 0, pwType, pvData, pbData);
|
|
|
|
RegCloseKey( hSubKey );
|
2001-02-13 20:17:59 +00:00
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHGetValueW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Gets a value from the registry
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHGetValueW(
|
|
|
|
HKEY hkey,
|
|
|
|
LPCWSTR pSubKey,
|
|
|
|
LPCWSTR pValue,
|
|
|
|
LPDWORD pwType,
|
|
|
|
LPVOID pvData,
|
|
|
|
LPDWORD pbData)
|
|
|
|
{
|
|
|
|
HKEY hSubKey;
|
|
|
|
DWORD res;
|
2001-02-13 20:17:59 +00:00
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
TRACE("(%s %s)\n", debugstr_w(pSubKey), debugstr_w(pValue));
|
2001-02-13 20:17:59 +00:00
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
if((res = RegOpenKeyW(hkey, pSubKey, &hSubKey))) return res;
|
|
|
|
res = RegQueryValueExW(hSubKey, pValue, 0, pwType, pvData, pbData);
|
|
|
|
RegCloseKey( hSubKey );
|
2001-02-13 20:17:59 +00:00
|
|
|
|
2000-07-26 17:51:32 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHSetValueA [SHLWAPI.@]
|
|
|
|
*/
|
2000-11-25 01:24:10 +00:00
|
|
|
HRESULT WINAPI SHSetValueA(
|
2000-07-26 17:51:32 +00:00
|
|
|
HKEY hkey,
|
|
|
|
LPCSTR pszSubKey,
|
|
|
|
LPCSTR pszValue,
|
|
|
|
DWORD dwType,
|
|
|
|
LPCVOID pvData,
|
|
|
|
DWORD cbData)
|
|
|
|
{
|
2000-11-25 01:24:10 +00:00
|
|
|
HKEY subkey;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = RegCreateKeyA(hkey,pszSubKey,&subkey);
|
|
|
|
if (!hres)
|
|
|
|
return hres;
|
|
|
|
hres = RegSetValueExA(subkey,pszValue,0,dwType,pvData,cbData);
|
|
|
|
RegCloseKey(subkey);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHSetValueW [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHSetValueW(
|
|
|
|
HKEY hkey,
|
|
|
|
LPCWSTR pszSubKey,
|
|
|
|
LPCWSTR pszValue,
|
|
|
|
DWORD dwType,
|
|
|
|
LPCVOID pvData,
|
|
|
|
DWORD cbData)
|
|
|
|
{
|
|
|
|
HKEY subkey;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = RegCreateKeyW(hkey,pszSubKey,&subkey);
|
|
|
|
if (!hres)
|
|
|
|
return hres;
|
|
|
|
hres = RegSetValueExW(subkey,pszValue,0,dwType,pvData,cbData);
|
|
|
|
RegCloseKey(subkey);
|
|
|
|
return hres;
|
2000-07-26 17:51:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHQueryValueExA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHQueryValueExA(
|
|
|
|
HKEY hkey,
|
|
|
|
LPSTR lpValueName,
|
|
|
|
LPDWORD lpReserved,
|
|
|
|
LPDWORD lpType,
|
|
|
|
LPBYTE lpData,
|
|
|
|
LPDWORD lpcbData)
|
|
|
|
{
|
|
|
|
TRACE("0x%04x %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
|
|
|
|
return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHQueryValueExW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* if the datatype REG_EXPAND_SZ then expand the string and change
|
2001-02-13 20:17:59 +00:00
|
|
|
* *pdwType to REG_SZ.
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHQueryValueExW (
|
|
|
|
HKEY hkey,
|
|
|
|
LPWSTR pszValue,
|
|
|
|
LPDWORD pdwReserved,
|
|
|
|
LPDWORD pdwType,
|
|
|
|
LPVOID pvData,
|
|
|
|
LPDWORD pcbData)
|
|
|
|
{
|
|
|
|
WARN("0x%04x %s %p %p %p %p semi-stub\n",
|
|
|
|
hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
|
|
|
|
return RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHDeleteKeyA [SHLWAPI.@]
|
2000-09-29 00:25:56 +00:00
|
|
|
*
|
|
|
|
* It appears this function is made available to account for the differences
|
|
|
|
* between the Win9x and WinNT/2k RegDeleteKeyA functions.
|
|
|
|
*
|
|
|
|
* According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
|
|
|
|
* WinNt/2k will only delete the key if empty.
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHDeleteKeyA(
|
2000-09-29 00:25:56 +00:00
|
|
|
HKEY hKey,
|
|
|
|
LPCSTR lpszSubKey)
|
2000-07-26 17:51:32 +00:00
|
|
|
{
|
2000-09-29 00:25:56 +00:00
|
|
|
DWORD r, dwKeyCount, dwSize, i, dwMaxSubkeyLen;
|
|
|
|
HKEY hSubKey;
|
|
|
|
LPSTR lpszName;
|
|
|
|
|
|
|
|
TRACE("hkey=0x%08x, %s\n", hKey, debugstr_a(lpszSubKey));
|
|
|
|
|
|
|
|
hSubKey = 0;
|
|
|
|
r = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
|
|
|
|
if(r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
/* find how many subkeys there are */
|
|
|
|
dwKeyCount = 0;
|
|
|
|
dwMaxSubkeyLen = 0;
|
2001-02-13 20:17:59 +00:00
|
|
|
r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
|
2000-09-29 00:25:56 +00:00
|
|
|
&dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if(r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegCloseKey(hSubKey);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* alloc memory for the longest string terminating 0 */
|
|
|
|
dwMaxSubkeyLen++;
|
|
|
|
lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen*sizeof(CHAR));
|
|
|
|
if(!lpszName)
|
|
|
|
{
|
|
|
|
RegCloseKey(hSubKey);
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* recursively delete all the subkeys */
|
|
|
|
for(i=0; i<dwKeyCount; i++)
|
|
|
|
{
|
|
|
|
dwSize = dwMaxSubkeyLen;
|
|
|
|
r = RegEnumKeyExA(hSubKey, i, lpszName, &dwSize, NULL, NULL, NULL, NULL);
|
|
|
|
if(r != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
r = SHDeleteKeyA(hSubKey, lpszName);
|
|
|
|
if(r != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpszName);
|
|
|
|
|
|
|
|
RegCloseKey(hSubKey);
|
|
|
|
|
|
|
|
if(r == ERROR_SUCCESS)
|
|
|
|
r = RegDeleteKeyA(hKey, lpszSubKey);
|
|
|
|
|
|
|
|
return r;
|
2000-07-26 17:51:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHDeleteKeyW [SHLWAPI.@]
|
2000-09-29 00:25:56 +00:00
|
|
|
*
|
|
|
|
* It appears this function is made available to account for the differences
|
|
|
|
* between the Win9x and WinNT/2k RegDeleteKeyA functions.
|
|
|
|
*
|
|
|
|
* According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
|
|
|
|
* WinNt/2k will only delete the key if empty.
|
2000-07-26 17:51:32 +00:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHDeleteKeyW(
|
|
|
|
HKEY hkey,
|
|
|
|
LPCWSTR pszSubKey)
|
|
|
|
{
|
|
|
|
FIXME("hkey=0x%08x, %s\n", hkey, debugstr_w(pszSubKey));
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-29 00:25:56 +00:00
|
|
|
|
2000-11-25 01:24:10 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHDeleteValueA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Function opens the key, get/set/delete the value, then close the key.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHDeleteValueA(HKEY hkey, LPCSTR pszSubKey, LPCSTR pszValue) {
|
|
|
|
HKEY subkey;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = RegOpenKeyA(hkey,pszSubKey,&subkey);
|
|
|
|
if (hres)
|
|
|
|
return hres;
|
|
|
|
hres = RegDeleteValueA(subkey,pszValue);
|
|
|
|
RegCloseKey(subkey);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHDeleteValueW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* Function opens the key, get/set/delete the value, then close the key.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHDeleteValueW(HKEY hkey, LPCWSTR pszSubKey, LPCWSTR pszValue) {
|
|
|
|
HKEY subkey;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = RegOpenKeyW(hkey,pszSubKey,&subkey);
|
|
|
|
if (hres)
|
|
|
|
return hres;
|
|
|
|
hres = RegDeleteValueW(subkey,pszValue);
|
|
|
|
RegCloseKey(subkey);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2000-09-29 00:25:56 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHDeleteEmptyKeyA [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* It appears this function is made available to account for the differences
|
|
|
|
* between the Win9x and WinNT/2k RegDeleteKeyA functions.
|
|
|
|
*
|
|
|
|
* According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
|
|
|
|
* WinNt/2k will only delete the key if empty.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHDeleteEmptyKeyA(HKEY hKey, LPCSTR lpszSubKey)
|
|
|
|
{
|
|
|
|
DWORD r, dwKeyCount;
|
|
|
|
HKEY hSubKey;
|
|
|
|
|
|
|
|
TRACE("hkey=0x%08x, %s\n", hKey, debugstr_a(lpszSubKey));
|
|
|
|
|
|
|
|
hSubKey = 0;
|
|
|
|
r = RegOpenKeyExA(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
|
|
|
|
if(r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
dwKeyCount = 0;
|
2001-02-13 20:17:59 +00:00
|
|
|
r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
|
2000-09-29 00:25:56 +00:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
if(r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
RegCloseKey(hSubKey);
|
|
|
|
|
|
|
|
if(dwKeyCount)
|
|
|
|
return ERROR_KEY_HAS_CHILDREN;
|
|
|
|
|
|
|
|
r = RegDeleteKeyA(hKey, lpszSubKey);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHDeleteEmptyKeyW [SHLWAPI.@]
|
|
|
|
*
|
|
|
|
* It appears this function is made available to account for the differences
|
|
|
|
* between the Win9x and WinNT/2k RegDeleteKeyA functions.
|
|
|
|
*
|
|
|
|
* According to docs, Win9x RegDeleteKeyA will delete all subkeys, whereas
|
|
|
|
* WinNt/2k will only delete the key if empty.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHDeleteEmptyKeyW(HKEY hKey, LPCWSTR lpszSubKey)
|
|
|
|
{
|
|
|
|
FIXME("hkey=0x%08x, %s\n", hKey, debugstr_w(lpszSubKey));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-02-13 20:17:59 +00:00
|
|
|
/*************************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* @ [SHLWAPI.205]
|
2001-02-13 20:17:59 +00:00
|
|
|
*
|
|
|
|
* Wrapper for SHGetValueA in case machine is in safe mode.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHLWAPI_205(HKEY hkey, LPCSTR pSubKey, LPCSTR pValue,
|
|
|
|
LPDWORD pwType, LPVOID pvData, LPDWORD pbData)
|
|
|
|
{
|
|
|
|
if (GetSystemMetrics(SM_CLEANBOOT))
|
|
|
|
return ERROR_INVALID_FUNCTION;
|
|
|
|
return SHGetValueA(hkey, pSubKey, pValue, pwType, pvData, pbData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* @ [SHLWAPI.206]
|
2001-02-13 20:17:59 +00:00
|
|
|
*
|
|
|
|
* Unicode version of SHLWAPI_205.
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHLWAPI_206(HKEY hkey, LPCWSTR pSubKey, LPCWSTR pValue,
|
|
|
|
LPDWORD pwType, LPVOID pvData, LPDWORD pbData)
|
|
|
|
{
|
|
|
|
if (GetSystemMetrics(SM_CLEANBOOT))
|
|
|
|
return ERROR_INVALID_FUNCTION;
|
|
|
|
return SHGetValueW(hkey, pSubKey, pValue, pwType, pvData, pbData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* @ [SHLWAPI.320]
|
2001-02-13 20:17:59 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SHLWAPI_320(LPCSTR lpszSubKey, LPCSTR lpszValue)
|
|
|
|
{
|
|
|
|
DWORD dwLen = strlen(lpszValue);
|
|
|
|
HRESULT ret = SHSetValueA(HKEY_CLASSES_ROOT, lpszSubKey, lpszContentTypeA,
|
|
|
|
REG_SZ, lpszValue, dwLen);
|
|
|
|
return ret ? FALSE : TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* @ [SHLWAPI.321]
|
2001-02-13 20:17:59 +00:00
|
|
|
*
|
|
|
|
* Unicode version of SHLWAPI_320.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SHLWAPI_321(LPCWSTR lpszSubKey, LPCWSTR lpszValue)
|
|
|
|
{
|
|
|
|
DWORD dwLen = strlenW(lpszValue);
|
|
|
|
HRESULT ret = SHSetValueW(HKEY_CLASSES_ROOT, lpszSubKey, lpszContentTypeW,
|
|
|
|
REG_SZ, lpszValue, dwLen);
|
|
|
|
return ret ? FALSE : TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* @ [SHLWAPI.322]
|
2001-02-13 20:17:59 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SHLWAPI_322(LPCSTR lpszSubKey)
|
|
|
|
{
|
|
|
|
HRESULT ret = SHDeleteValueA(HKEY_CLASSES_ROOT, lpszSubKey, lpszContentTypeA);
|
|
|
|
return ret ? FALSE : TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-07-02 19:59:40 +00:00
|
|
|
* @ [SHLWAPI.323]
|
2001-02-13 20:17:59 +00:00
|
|
|
*
|
|
|
|
* Unicode version of SHLWAPI_322.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SHLWAPI_323(LPCWSTR lpszSubKey)
|
|
|
|
{
|
|
|
|
HRESULT ret = SHDeleteValueW(HKEY_CLASSES_ROOT, lpszSubKey, lpszContentTypeW);
|
|
|
|
return ret ? FALSE : TRUE;
|
|
|
|
}
|
|
|
|
|
2001-12-01 00:37:12 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SHRegDuplicateHKey [SHLWAPI.@]
|
|
|
|
*/
|
|
|
|
HKEY WINAPI SHRegDuplicateHKey(HKEY hKey)
|
|
|
|
{
|
|
|
|
HKEY newKey = 0;
|
|
|
|
|
|
|
|
RegOpenKeyExA(hKey, 0, 0, MAXIMUM_ALLOWED, &newKey);
|
|
|
|
TRACE("new key is %08x\n", newKey);
|
|
|
|
return newKey;
|
|
|
|
}
|