Reactos
at master 186 lines 5.1 kB view raw
1/* 2 * Shell Registry Access 3 * 4 * Copyright 2000 Juergen Schmied 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 */ 20 21#include <wine/config.h> 22 23#include <stdio.h> 24 25#define WIN32_NO_STATUS 26#define _INC_WINDOWS 27 28#include <windef.h> 29#include <winbase.h> 30#include <shlobj.h> 31#include <shlwapi.h> 32#include <wine/debug.h> 33 34#include "shell32_main.h" 35 36WINE_DEFAULT_DEBUG_CHANNEL(shell); 37 38/************************************************************************* 39 * SHRegOpenKeyA [SHELL32.506] 40 * 41 */ 42HRESULT WINAPI SHRegOpenKeyA( 43 HKEY hKey, 44 LPSTR lpSubKey, 45 PHKEY phkResult) 46{ 47 TRACE("(%p, %s, %p)\n", hKey, debugstr_a(lpSubKey), phkResult); 48 return RegOpenKeyA(hKey, lpSubKey, phkResult); 49} 50 51/************************************************************************* 52 * SHRegOpenKeyW [SHELL32.507] NT 4.0 53 * 54 */ 55HRESULT WINAPI SHRegOpenKeyW ( 56 HKEY hkey, 57 LPCWSTR lpszSubKey, 58 PHKEY retkey) 59{ 60 WARN("%p %s %p\n",hkey,debugstr_w(lpszSubKey),retkey); 61 return RegOpenKeyW( hkey, lpszSubKey, retkey ); 62} 63 64/************************************************************************* 65 * SHRegQueryValueA [SHELL32.508] 66 * 67 */ 68HRESULT WINAPI SHRegQueryValueA(HKEY hkey, LPSTR lpSubKey, LPSTR lpValue, LPDWORD lpcbValue) 69{ 70 TRACE("(%p %s %p %p)\n", hkey, debugstr_a(lpSubKey), lpValue, lpcbValue); 71 return RegQueryValueA(hkey, lpSubKey, lpValue, (LONG*)lpcbValue); 72} 73 74/************************************************************************* 75 * SHRegQueryValueExA [SHELL32.509] 76 * 77 */ 78LONG WINAPI SHRegQueryValueExA( 79 HKEY hkey, 80 LPCSTR lpValueName, 81 LPDWORD lpReserved, 82 LPDWORD lpType, 83 LPBYTE lpData, 84 LPDWORD lpcbData) 85{ 86 TRACE("%p %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData); 87 return SHQueryValueExA(hkey, lpValueName, lpReserved, lpType, lpData, lpcbData); 88} 89 90/************************************************************************* 91 * SHRegQueryValueW [SHELL32.510] NT4.0 92 * 93 */ 94HRESULT WINAPI SHRegQueryValueW( 95 HKEY hkey, 96 LPWSTR lpszSubKey, 97 LPWSTR lpszData, 98 LPDWORD lpcbData ) 99{ 100 WARN("%p %s %p %p semi-stub\n", 101 hkey, debugstr_w(lpszSubKey), lpszData, lpcbData); 102 return RegQueryValueW( hkey, lpszSubKey, lpszData, (LONG*)lpcbData ); 103} 104 105/************************************************************************* 106 * SHRegQueryValueExW [SHELL32.511] NT4.0 107 */ 108LONG WINAPI SHRegQueryValueExW( 109 HKEY hkey, 110 LPCWSTR pszValue, 111 LPDWORD pdwReserved, 112 LPDWORD pdwType, 113 LPVOID pvData, 114 LPDWORD pcbData) 115{ 116 TRACE("%p %s %p %p %p %p\n", 117 hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData); 118 return SHQueryValueExW(hkey, pszValue, pdwReserved, pdwType, pvData, pcbData); 119} 120 121/************************************************************************* 122 * SHRegDeleteKeyW [SHELL32.512] 123 */ 124HRESULT WINAPI SHRegDeleteKeyW( 125 HKEY hkey, 126 LPCWSTR pszSubKey) 127{ 128 FIXME("hkey=%p, %s\n", hkey, debugstr_w(pszSubKey)); 129 return 0; 130} 131 132/************************************************************************* 133 * SHRegCloseKey [SHELL32.505] NT 4.0 134 * 135 */ 136HRESULT WINAPI SHRegCloseKey (HKEY hkey) 137{ 138 TRACE("%p\n",hkey); 139 return RegCloseKey( hkey ); 140} 141 142/************************************************************************* 143 * SHCreateSessionKey [SHELL32.723] 144 */ 145HRESULT 146WINAPI 147SHCreateSessionKey(REGSAM samDesired, PHKEY phKey) 148{ 149 HRESULT hr = S_OK; 150 static WCHAR wszSessionKey[256]; 151 LONG Error; 152 153 if (!wszSessionKey[0]) // FIXME: Critical Section 154 { 155 HANDLE hToken; 156 157 if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &hToken)) 158 { 159 TOKEN_STATISTICS Stats; 160 DWORD ReturnLength; 161 162 if (GetTokenInformation(hToken, TokenStatistics, &Stats, sizeof(Stats), &ReturnLength)) 163 { 164 swprintf(wszSessionKey, 165 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\SessionInfo\\%08x%08x", 166 Stats.AuthenticationId.HighPart, Stats.AuthenticationId.LowPart); 167 } 168 else 169 hr = HRESULT_FROM_WIN32(GetLastError()); 170 171 CloseHandle(hToken); 172 } 173 else 174 hr = HRESULT_FROM_WIN32(GetLastError()); 175 } 176 177 if(SUCCEEDED(hr)) 178 { 179 Error = RegCreateKeyExW(HKEY_LOCAL_MACHINE, wszSessionKey, 0, NULL, 180 REG_OPTION_VOLATILE, samDesired, NULL, phKey, NULL); 181 if (Error != ERROR_SUCCESS) 182 hr = HRESULT_FROM_WIN32(Error); 183 } 184 185 return hr; 186}