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