user32/tests: Fix monitor test failures on some systems.
[wine.git] / dlls / shell32 / shellreg.c
blob2ecd0af754a53161a2eca7fdd7de08ab410ca0d5
1 /*
2 * Shell Registry Access
4 * Copyright 2000 Juergen Schmied
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.
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.
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
21 #include "config.h"
23 #include <string.h>
24 #include <stdarg.h>
25 #include <stdio.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "shellapi.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "shlobj.h"
33 #include "winreg.h"
35 #include "undocshell.h"
36 #include "shell32_main.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(shell);
42 /*************************************************************************
43 * SHRegOpenKeyA [SHELL32.506]
46 HRESULT WINAPI SHRegOpenKeyA(
47 HKEY hKey,
48 LPSTR lpSubKey,
49 PHKEY phkResult)
51 TRACE("(%p, %s, %p)\n", hKey, debugstr_a(lpSubKey), phkResult);
52 return RegOpenKeyA(hKey, lpSubKey, phkResult);
55 /*************************************************************************
56 * SHRegOpenKeyW [SHELL32.507] NT 4.0
59 HRESULT WINAPI SHRegOpenKeyW (
60 HKEY hkey,
61 LPCWSTR lpszSubKey,
62 PHKEY retkey)
64 WARN("%p %s %p\n",hkey,debugstr_w(lpszSubKey),retkey);
65 return RegOpenKeyW( hkey, lpszSubKey, retkey );
68 /*************************************************************************
69 * SHRegQueryValueA [SHELL32.508]
72 HRESULT WINAPI SHRegQueryValueA(HKEY hkey, LPSTR lpSubKey, LPSTR lpValue, LPDWORD lpcbValue)
74 TRACE("(%p %s %p %p)\n", hkey, debugstr_a(lpSubKey), lpValue, lpcbValue);
75 return RegQueryValueA(hkey, lpSubKey, lpValue, (LONG*)lpcbValue);
78 /*************************************************************************
79 * SHRegQueryValueExA [SHELL32.509]
82 HRESULT WINAPI SHRegQueryValueExA(
83 HKEY hkey,
84 LPSTR lpValueName,
85 LPDWORD lpReserved,
86 LPDWORD lpType,
87 LPBYTE lpData,
88 LPDWORD lpcbData)
90 TRACE("%p %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
91 return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
94 /*************************************************************************
95 * SHRegQueryValueW [SHELL32.510] NT4.0
98 HRESULT WINAPI SHRegQueryValueW(
99 HKEY hkey,
100 LPWSTR lpszSubKey,
101 LPWSTR lpszData,
102 LPDWORD lpcbData )
104 WARN("%p %s %p %p semi-stub\n",
105 hkey, debugstr_w(lpszSubKey), lpszData, lpcbData);
106 return RegQueryValueW( hkey, lpszSubKey, lpszData, (LONG*)lpcbData );
109 /*************************************************************************
110 * SHRegQueryValueExW [SHELL32.511] NT4.0
112 * FIXME
113 * if the datatype REG_EXPAND_SZ then expand the string and change
114 * *pdwType to REG_SZ.
116 HRESULT WINAPI SHRegQueryValueExW (
117 HKEY hkey,
118 LPWSTR pszValue,
119 LPDWORD pdwReserved,
120 LPDWORD pdwType,
121 LPVOID pvData,
122 LPDWORD pcbData)
124 DWORD ret;
125 WARN("%p %s %p %p %p %p semi-stub\n",
126 hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
127 ret = RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
128 return ret;
131 /*************************************************************************
132 * SHRegDeleteKeyW [SHELL32.512]
134 HRESULT WINAPI SHRegDeleteKeyW(
135 HKEY hkey,
136 LPCWSTR pszSubKey)
138 FIXME("hkey=%p, %s\n", hkey, debugstr_w(pszSubKey));
139 return 0;
142 /*************************************************************************
143 * SHRegCloseKey [SHELL32.505] NT 4.0
146 HRESULT WINAPI SHRegCloseKey (HKEY hkey)
148 TRACE("%p\n",hkey);
149 return RegCloseKey( hkey );
152 /*************************************************************************
153 * SHCreateSessionKey [SHELL32.723]
156 HRESULT WINAPI SHCreateSessionKey(REGSAM access, HKEY *hkey)
158 static const WCHAR session_format[] = {
159 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
160 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
161 'E','x','p','l','o','r','e','r','\\','S','e','s','s','i','o','n','I','n','f','o','\\','%','u',0};
162 DWORD session, ret;
163 WCHAR str[ARRAY_SIZE(session_format) + 16];
165 if (hkey)
166 *hkey = NULL;
168 if (!access)
169 return E_ACCESSDENIED;
171 if (!ProcessIdToSessionId(GetCurrentProcessId(), &session))
172 return E_INVALIDARG;
174 sprintfW(str, session_format, session);
175 TRACE("using session key %s\n", debugstr_w(str));
177 ret = RegCreateKeyExW(HKEY_CURRENT_USER, str, 0, NULL, REG_OPTION_VOLATILE, access, NULL, hkey, NULL);
178 return HRESULT_FROM_WIN32( ret );