New XP debugging APIs: implemented DebugActiveProcessStop,
[wine] / dlls / shell32 / shellreg.c
1 /*
2         Shell Registry Access
3 */
4
5 #include "config.h"
6
7 #include <string.h>
8 #include <stdio.h>
9
10 #include "shellapi.h"
11 #include "shlobj.h"
12 #include "winerror.h"
13 #include "winreg.h"
14 #include "winnls.h"
15
16 #include "undocshell.h"
17 #include "wine/winbase16.h"
18 #include "shell32_main.h"
19
20 #include "debugtools.h"
21
22 DEFAULT_DEBUG_CHANNEL(shell);
23
24 /*************************************************************************
25  * SHRegOpenKeyA                                [SHELL32.506]
26  *
27  */
28 HRESULT WINAPI SHRegOpenKeyA(
29         HKEY hKey,
30         LPSTR lpSubKey,
31         LPHKEY phkResult)
32 {
33         TRACE("(0x%08x, %s, %p)\n", hKey, debugstr_a(lpSubKey), phkResult);
34         return RegOpenKeyA(hKey, lpSubKey, phkResult);
35 }
36
37 /*************************************************************************
38  * SHRegOpenKeyW                                [SHELL32.507] NT 4.0
39  *
40  */
41 HRESULT WINAPI SHRegOpenKeyW (
42         HKEY hkey,
43         LPCWSTR lpszSubKey,
44         LPHKEY retkey)
45 {
46         WARN("0x%04x %s %p\n",hkey,debugstr_w(lpszSubKey),retkey);
47         return RegOpenKeyW( hkey, lpszSubKey, retkey );
48 }
49
50 /*************************************************************************
51  * SHRegQueryValueExA   [SHELL32.509]
52  *
53  */
54 HRESULT WINAPI SHRegQueryValueExA(
55         HKEY hkey,
56         LPSTR lpValueName,
57         LPDWORD lpReserved,
58         LPDWORD lpType,
59         LPBYTE lpData,
60         LPDWORD lpcbData)
61 {
62         TRACE("0x%04x %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
63         return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
64 }
65
66 /*************************************************************************
67  * SHRegQueryValueW                             [SHELL32.510] NT4.0
68  *
69  */
70 HRESULT WINAPI SHRegQueryValueW(
71         HKEY hkey,
72         LPWSTR lpszSubKey,
73         LPWSTR lpszData,
74         LPDWORD lpcbData )
75 {
76         WARN("0x%04x %s %p %p semi-stub\n",
77                 hkey, debugstr_w(lpszSubKey), lpszData, lpcbData);
78         return RegQueryValueW( hkey, lpszSubKey, lpszData, lpcbData );
79 }
80
81 /*************************************************************************
82  * SHRegQueryValueExW   [SHELL32.511] NT4.0
83  *
84  * FIXME 
85  *  if the datatype REG_EXPAND_SZ then expand the string and change
86  *  *pdwType to REG_SZ. 
87  */
88 HRESULT WINAPI SHRegQueryValueExW (
89         HKEY hkey,
90         LPWSTR pszValue,
91         LPDWORD pdwReserved,
92         LPDWORD pdwType,
93         LPVOID pvData,
94         LPDWORD pcbData)
95 {
96         DWORD ret;
97         WARN("0x%04x %s %p %p %p %p semi-stub\n",
98                 hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
99         ret = RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
100         return ret;
101 }
102
103 /*************************************************************************
104  * SHRegDeleteKeyA   [SHELL32.?]
105  */
106 HRESULT WINAPI SHRegDeleteKeyA(
107         HKEY hkey,
108         LPCSTR pszSubKey)
109 {
110         FIXME("hkey=0x%08x, %s\n", hkey, debugstr_a(pszSubKey));
111         return 0;
112 }
113
114 /*************************************************************************
115  * SHRegDeleteKeyW   [SHELL32.512]
116  */
117 HRESULT WINAPI SHRegDeleteKeyW(
118         HKEY hkey,
119         LPCWSTR pszSubKey)
120 {
121         FIXME("hkey=0x%08x, %s\n", hkey, debugstr_w(pszSubKey));
122         return 0;
123 }
124
125 /*************************************************************************
126  * SHRegCloseKey                        [SHELL32.505] NT 4.0
127  *
128  */
129 HRESULT WINAPI SHRegCloseKey (HKEY hkey)
130 {
131         TRACE("0x%04x\n",hkey);
132         return RegCloseKey( hkey );
133 }
134
135
136 /* 16-bit functions */
137
138 /* 0 and 1 are valid rootkeys in win16 shell.dll and are used by
139  * some programs. Do not remove those cases. -MM
140  */
141 static inline void fix_win16_hkey( HKEY *hkey )
142 {
143     if (*hkey == 0 || *hkey == 1) *hkey = HKEY_CLASSES_ROOT;
144 }
145
146 /******************************************************************************
147  *           RegOpenKey   [SHELL.1]
148  */
149 DWORD WINAPI RegOpenKey16( HKEY hkey, LPCSTR name, LPHKEY retkey )
150 {
151     fix_win16_hkey( &hkey );
152     return RegOpenKeyA( hkey, name, retkey );
153 }
154
155 /******************************************************************************
156  *           RegCreateKey   [SHELL.2]
157  */
158 DWORD WINAPI RegCreateKey16( HKEY hkey, LPCSTR name, LPHKEY retkey )
159 {
160     fix_win16_hkey( &hkey );
161     return RegCreateKeyA( hkey, name, retkey );
162 }
163
164 /******************************************************************************
165  *           RegCloseKey   [SHELL.3]
166  */
167 DWORD WINAPI RegCloseKey16( HKEY hkey )
168 {
169     fix_win16_hkey( &hkey );
170     return RegCloseKey( hkey );
171 }
172
173 /******************************************************************************
174  *           RegDeleteKey   [SHELL.4]
175  */
176 DWORD WINAPI RegDeleteKey16( HKEY hkey, LPCSTR name )
177 {
178     fix_win16_hkey( &hkey );
179     return RegDeleteKeyA( hkey, name );
180 }
181
182 /******************************************************************************
183  *           RegSetValue   [SHELL.5]
184  */
185 DWORD WINAPI RegSetValue16( HKEY hkey, LPCSTR name, DWORD type, LPCSTR data, DWORD count )
186 {
187     fix_win16_hkey( &hkey );
188     return RegSetValueA( hkey, name, type, data, count );
189 }
190
191 /******************************************************************************
192  *           RegQueryValue   [SHELL.6]
193  *
194  * NOTES
195  *    Is this HACK still applicable?
196  *
197  * HACK
198  *    The 16bit RegQueryValue doesn't handle selectorblocks anyway, so we just
199  *    mask out the high 16 bit.  This (not so much incidently) hopefully fixes
200  *    Aldus FH4)
201  */
202 DWORD WINAPI RegQueryValue16( HKEY hkey, LPCSTR name, LPSTR data, LPDWORD count )
203 {
204     fix_win16_hkey( &hkey );
205     if (count) *count &= 0xffff;
206     return RegQueryValueA( hkey, name, data, count );
207 }
208
209 /******************************************************************************
210  *           RegEnumKey   [SHELL.7]
211  */
212 DWORD WINAPI RegEnumKey16( HKEY hkey, DWORD index, LPSTR name, DWORD name_len )
213 {
214     fix_win16_hkey( &hkey );
215     return RegEnumKeyA( hkey, index, name, name_len );
216 }