- Implement HUSKEY design.

- Implement functions: SHRegOpenUSKey{A|W}, SHRegCloseUSKey,
  SHRegGetUSValue{A|W}, SHRegQueryInfoUSKey{A|W}
This commit is contained in:
Guy L. Albertelli 2001-10-21 15:09:36 +00:00 committed by Alexandre Julliard
parent 2cf83ba009
commit 06fb2139b0
2 changed files with 264 additions and 43 deletions

View File

@ -8,6 +8,7 @@
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "winerror.h" #include "winerror.h"
#include "winnls.h"
#include "winreg.h" #include "winreg.h"
#include "debugtools.h" #include "debugtools.h"
#include "shlwapi.h" #include "shlwapi.h"
@ -18,6 +19,143 @@ DEFAULT_DEBUG_CHANNEL(shell);
static const char *lpszContentTypeA = "Content Type"; static const char *lpszContentTypeA = "Content Type";
static const WCHAR lpszContentTypeW[] = { 'C','o','n','t','e','n','t',' ','T','y','p','e','\0'}; static const WCHAR lpszContentTypeW[] = { 'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
/* internal structure of what the HUSKEY points to */
typedef struct {
HKEY realkey; /* HKEY of opened key */
HKEY start; /* HKEY of where to start */
WCHAR key_string[MAX_PATH]; /* additional path from 'start' */
} Internal_HUSKEY, *LPInternal_HUSKEY;
/*************************************************************************
* SHRegOpenUSKeyA [SHLWAPI.@]
*
* Opens a user-specific registry key
*/
LONG WINAPI SHRegOpenUSKeyA(
LPCSTR Path,
REGSAM AccessType,
HUSKEY hRelativeUSKey,
PHUSKEY phNewUSKey,
BOOL fIgnoreHKCU)
{
HKEY startpoint, openkey;
LONG ret = ~ERROR_SUCCESS;
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");
if (hRelativeUSKey)
startpoint = ((LPInternal_HUSKEY)hRelativeUSKey)->realkey;
else {
startpoint = HKEY_LOCAL_MACHINE;
if (!fIgnoreHKCU) {
ret = RegOpenKeyExA(HKEY_CURRENT_USER, Path,
0, AccessType, &openkey);
/* if successful, then save real starting point */
if (ret == ERROR_SUCCESS)
startpoint = HKEY_CURRENT_USER;
}
}
/* if current_user didn't have it, or have relative start point,
* try it.
*/
if (ret != ERROR_SUCCESS)
ret = RegOpenKeyExA(startpoint, Path, 0, AccessType, &openkey);
/* if all attempts have failed then bail */
if (ret != ERROR_SUCCESS) {
TRACE("failed %ld\n", ret);
return ret;
}
/* now create the internal version of HUSKEY */
ihky = (LPInternal_HUSKEY)HeapAlloc(GetProcessHeap(), 0 ,
sizeof(Internal_HUSKEY));
ihky->realkey = openkey;
ihky->start = startpoint;
MultiByteToWideChar(0, 0, Path, -1, ihky->key_string,
sizeof(ihky->key_string)-1);
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)
{
HKEY startpoint, openkey;
LONG ret = ~ERROR_SUCCESS;
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");
if (hRelativeUSKey)
startpoint = ((LPInternal_HUSKEY)hRelativeUSKey)->realkey;
else {
startpoint = HKEY_LOCAL_MACHINE;
if (!fIgnoreHKCU) {
ret = RegOpenKeyExW(HKEY_CURRENT_USER, Path,
0, AccessType, &openkey);
/* if successful, then save real starting point */
if (ret == ERROR_SUCCESS)
startpoint = HKEY_CURRENT_USER;
}
}
/* if current_user didn't have it, or have relative start point,
* try it.
*/
if (ret != ERROR_SUCCESS)
ret = RegOpenKeyExW(startpoint, Path, 0, AccessType, &openkey);
/* if all attempts have failed then bail */
if (ret != ERROR_SUCCESS) {
TRACE("failed %ld\n", ret);
return ret;
}
/* now create the internal version of HUSKEY */
ihky = (LPInternal_HUSKEY)HeapAlloc(GetProcessHeap(), 0 ,
sizeof(Internal_HUSKEY));
ihky->realkey = openkey;
ihky->start = startpoint;
lstrcpynW(ihky->key_string, Path, sizeof(ihky->key_string));
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;
LONG ret;
ret = RegCloseKey(mihk->realkey);
HeapFree(GetProcessHeap(), 0, mihk);
return ret;
}
/************************************************************************* /*************************************************************************
* SHRegGetUSValueA [SHLWAPI.@] * SHRegGetUSValueA [SHLWAPI.@]
* *
@ -28,13 +166,40 @@ LONG WINAPI SHRegGetUSValueA(
LPCSTR pValue, LPCSTR pValue,
LPDWORD pwType, LPDWORD pwType,
LPVOID pvData, LPVOID pvData,
LPDWORD pbData, LPDWORD pcbData,
BOOL fIgnoreHKCU, BOOL flagIgnoreHKCU,
LPVOID pDefaultData, LPVOID pDefaultData,
DWORD wDefaultDataSize) DWORD wDefaultDataSize)
{ {
FIXME("(%p),stub!\n", pSubKey); HUSKEY myhuskey;
return ERROR_SUCCESS; /* return success */ LPInternal_HUSKEY mihk;
LONG ret, maxmove, i;
CHAR *src, *dst;
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,
(flagIgnoreHKCU) ? "Ignoring HKCU" : "Trys HKCU then HKLM");
ret = SHRegOpenUSKeyA(pSubKey, 0x1, 0, &myhuskey, flagIgnoreHKCU);
if (ret == ERROR_SUCCESS) {
mihk = (LPInternal_HUSKEY) myhuskey;
ret = RegQueryValueExA(mihk->realkey, pValue, 0, pwType,
(LPBYTE)pvData, pcbData);
SHRegCloseUSKey(myhuskey);
}
if (ret != ERROR_SUCCESS) {
if (pDefaultData && (wDefaultDataSize != 0)) {
maxmove = (wDefaultDataSize >= *pcbData) ? *pcbData : wDefaultDataSize;
src = (CHAR*)pDefaultData;
dst = (CHAR*)pvData;
for(i=0; i<maxmove; i++) *dst++ = *src++;
*pcbData = maxmove;
TRACE("setting default data\n");
ret = ERROR_SUCCESS;
}
}
return ret;
} }
/************************************************************************* /*************************************************************************
@ -47,45 +212,40 @@ LONG WINAPI SHRegGetUSValueW(
LPCWSTR pValue, LPCWSTR pValue,
LPDWORD pwType, LPDWORD pwType,
LPVOID pvData, LPVOID pvData,
LPDWORD pbData, LPDWORD pcbData,
BOOL flagIgnoreHKCU, BOOL flagIgnoreHKCU,
LPVOID pDefaultData, LPVOID pDefaultData,
DWORD wDefaultDataSize) DWORD wDefaultDataSize)
{ {
FIXME("(%p),stub!\n", pSubKey); HUSKEY myhuskey;
return ERROR_SUCCESS; /* return success */ LPInternal_HUSKEY mihk;
} LONG ret, maxmove, i;
CHAR *src, *dst;
/************************************************************************* if (!pvData || !pcbData) return ERROR_INVALID_FUNCTION; /* FIXME:wrong*/
* SHRegOpenUSKeyA [SHLWAPI.@] TRACE("key '%s', value '%s', datalen %ld, %s\n",
* debugstr_w(pSubKey), debugstr_w(pValue), *pcbData,
* Opens a user-specific registry key (flagIgnoreHKCU) ? "Ignoring HKCU" : "Trys HKCU then HKLM");
*/
LONG WINAPI SHRegOpenUSKeyA(
LPCSTR Path,
REGSAM AccessType,
HKEY hRelativeUSKey,
HKEY hNewUSKey,
BOOL fIgnoreHKCU)
{
FIXME("stub!\n");
return ERROR_SUCCESS; /* return success */
}
/************************************************************************* ret = SHRegOpenUSKeyW(pSubKey, 0x1, 0, &myhuskey, flagIgnoreHKCU);
* SHRegOpenUSKeyW [SHLWAPI.@] if (ret == ERROR_SUCCESS) {
* mihk = (LPInternal_HUSKEY) myhuskey;
* Openss a user-specific registry key ret = RegQueryValueExW(mihk->realkey, pValue, 0, pwType,
*/ (LPBYTE)pvData, pcbData);
LONG WINAPI SHRegOpenUSKeyW( SHRegCloseUSKey(myhuskey);
LPCSTR Path, }
REGSAM AccessType, if (ret != ERROR_SUCCESS) {
HKEY hRelativeUSKey, if (pDefaultData && (wDefaultDataSize != 0)) {
HKEY hNewUSKey, maxmove = (wDefaultDataSize >= *pcbData) ? *pcbData : wDefaultDataSize;
BOOL fIgnoreHKCU) src = (CHAR*)pDefaultData;
{ dst = (CHAR*)pvData;
FIXME("stub!\n"); for(i=0; i<maxmove; i++) *dst++ = *src++;
return ERROR_SUCCESS; /* return success */ *pcbData = maxmove;
TRACE("setting default data\n");
ret = ERROR_SUCCESS;
}
}
return ret;
} }
/************************************************************************* /*************************************************************************
@ -118,7 +278,7 @@ BOOL WINAPI SHRegGetBoolUSValueW(
* SHRegQueryUSValueA [SHLWAPI.@] * SHRegQueryUSValueA [SHLWAPI.@]
*/ */
LONG WINAPI SHRegQueryUSValueA( LONG WINAPI SHRegQueryUSValueA(
HKEY hUSKey, /* [in] FIXME: HUSKEY */ HUSKEY hUSKey, /* [in] */
LPCSTR pszValue, LPCSTR pszValue,
LPDWORD pdwType, LPDWORD pdwType,
void *pvData, void *pvData,
@ -135,7 +295,7 @@ LONG WINAPI SHRegQueryUSValueA(
* SHRegQueryUSValueW [SHLWAPI.@] * SHRegQueryUSValueW [SHLWAPI.@]
*/ */
LONG WINAPI SHRegQueryUSValueW( LONG WINAPI SHRegQueryUSValueW(
HKEY hUSKey, /* [in] FIXME: HUSKEY */ HUSKEY hUSKey, /* [in] */
LPCSTR pszValue, LPCSTR pszValue,
LPDWORD pdwType, LPDWORD pdwType,
void *pvData, void *pvData,
@ -148,15 +308,53 @@ LONG WINAPI SHRegQueryUSValueW(
return 1; return 1;
} }
/*************************************************************************
* SHRegQueryInfoUSKeyA [SHLWAPI.@]
*/
DWORD WINAPI SHRegQueryInfoUSKeyA(
HUSKEY hUSKey, /* [in] FIXME: HUSKEY */
LPDWORD pcSubKeys,
LPDWORD pcchMaxSubKeyLen,
LPDWORD pcValues,
LPDWORD pcchMaxValueNameLen,
SHREGENUM_FLAGS enumRegFlags)
{
TRACE("(0x%lx,%p,%p,%p,%p,%d)\n",
(LONG)hUSKey, pcSubKeys, pcchMaxSubKeyLen, pcValues,
pcchMaxValueNameLen, enumRegFlags);
return RegQueryInfoKeyA(((LPInternal_HUSKEY)hUSKey)->realkey, 0, 0, 0,
pcSubKeys, pcchMaxSubKeyLen, 0,
pcValues, pcchMaxValueNameLen, 0, 0, 0);
}
/*************************************************************************
* SHRegQueryInfoUSKeyW [SHLWAPI.@]
*/
DWORD WINAPI SHRegQueryInfoUSKeyW(
HUSKEY hUSKey, /* [in] FIXME: HUSKEY */
LPDWORD pcSubKeys,
LPDWORD pcchMaxSubKeyLen,
LPDWORD pcValues,
LPDWORD pcchMaxValueNameLen,
SHREGENUM_FLAGS enumRegFlags)
{
TRACE("(0x%lx,%p,%p,%p,%p,%d)\n",
(LONG)hUSKey,pcSubKeys,pcchMaxSubKeyLen,pcValues,
pcchMaxValueNameLen,enumRegFlags);
return RegQueryInfoKeyW(((LPInternal_HUSKEY)hUSKey)->realkey, 0, 0, 0,
pcSubKeys, pcchMaxSubKeyLen, 0,
pcValues, pcchMaxValueNameLen, 0, 0, 0);
}
/************************************************************************* /*************************************************************************
* SHRegEnumUSKeyA [SHLWAPI.@] * SHRegEnumUSKeyA [SHLWAPI.@]
*/ */
LONG WINAPI SHRegEnumUSKeyA( LONG WINAPI SHRegEnumUSKeyA(
HKEY hUSKey, /* [in] FIXME: HUSKEY */ HUSKEY hUSKey, /* [in] */
DWORD dwIndex, DWORD dwIndex,
LPSTR pszName, LPSTR pszName,
LPDWORD pcchValueNameLen, LPDWORD pcchValueNameLen,
DWORD enumRegFlags) /* [in] FIXME: SHREGENUM_FLAGS */ SHREGENUM_FLAGS enumRegFlags) /* [in] */
{ {
FIXME("%s stub\n",debugstr_a(pszName)); FIXME("%s stub\n",debugstr_a(pszName));
return ERROR_NO_MORE_ITEMS; return ERROR_NO_MORE_ITEMS;
@ -166,11 +364,11 @@ LONG WINAPI SHRegEnumUSKeyA(
* SHRegEnumUSKeyW [SHLWAPI.@] * SHRegEnumUSKeyW [SHLWAPI.@]
*/ */
LONG WINAPI SHRegEnumUSKeyW( LONG WINAPI SHRegEnumUSKeyW(
HKEY hUSKey, /* [in] FIXME: HUSKEY */ HUSKEY hUSKey, /* [in] */
DWORD dwIndex, DWORD dwIndex,
LPWSTR pszName, LPWSTR pszName,
LPDWORD pcchValueNameLen, LPDWORD pcchValueNameLen,
DWORD enumRegFlags) /* [in] FIXME: SHREGENUM_FLAGS */ SHREGENUM_FLAGS enumRegFlags) /* [in] */
{ {
FIXME("%s stub\n",debugstr_w(pszName)); FIXME("%s stub\n",debugstr_w(pszName));
return ERROR_NO_MORE_ITEMS; return ERROR_NO_MORE_ITEMS;

View File

@ -214,6 +214,9 @@ HRESULT WINAPI StrRetToBufA(struct _STRRET *src, const struct _ITEMIDLIST *pidl,
HRESULT WINAPI StrRetToBufW(struct _STRRET *src, const struct _ITEMIDLIST *pidl, LPWSTR dest, DWORD len); HRESULT WINAPI StrRetToBufW(struct _STRRET *src, const struct _ITEMIDLIST *pidl, LPWSTR dest, DWORD len);
#define StrRetToBuf WINELIB_NAME_AW(StrRetToBuf) #define StrRetToBuf WINELIB_NAME_AW(StrRetToBuf)
/* Shell Registry interfaces */
HRESULT WINAPI SHQueryValueExA(HKEY hkey, LPSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData); HRESULT WINAPI SHQueryValueExA(HKEY hkey, LPSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
HRESULT WINAPI SHQueryValueExW(HKEY hkey, LPWSTR pszValue, LPDWORD pdwReserved, LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData); HRESULT WINAPI SHQueryValueExW(HKEY hkey, LPWSTR pszValue, LPDWORD pdwReserved, LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData);
#define SHQueryValueEx WINELIB_NAME_AW(SHQueryValueEx) #define SHQueryValueEx WINELIB_NAME_AW(SHQueryValueEx)
@ -226,6 +229,26 @@ DWORD WINAPI SHDeleteEmptyKeyA(HKEY hKey, LPCSTR lpszSubKey);
DWORD WINAPI SHDeleteEmptyKeyW(HKEY hKey, LPCWSTR lpszSubKey); DWORD WINAPI SHDeleteEmptyKeyW(HKEY hKey, LPCWSTR lpszSubKey);
#define SHDeleteEmptyKey WINELIB_NAME_AW(SHDeleteEmptyKey) #define SHDeleteEmptyKey WINELIB_NAME_AW(SHDeleteEmptyKey)
typedef HANDLE HUSKEY;
typedef HUSKEY *PHUSKEY;
typedef enum {
SHREGDEL_DEFAULT = 0, /* delete HKCU if found or HKLM if not */
SHREGDEL_HKCU = 0x01, /* delete HKCU */
SHREGDEL_HKLM = 0x10, /* delete HKLM */
SHREGDEL_BOTH = 0x11, /* delete HKCU *and* HKLM */
} SHREGDEL_FLAGS;
typedef enum {
SHREGENUM_DEFAULT = 0, /* do HKCU or HKLM if not found */
SHREGENUM_HKCU = 0x01, /* do HKCU only */
SHREGENUM_HKLM = 0x10, /* do HKLM only */
SHREGENUM_BOTH = 0x11, /* do both HKCU and HKLM without dups */
} SHREGENUM_FLAGS;
HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized, HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
LPDWORD pcchCanonicalized, DWORD dwFlags); LPDWORD pcchCanonicalized, DWORD dwFlags);
HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,