blob: 7146d1754da3fdafb311ded2fc7d56f55c1f15c2 [file] [log] [blame]
Vincent BĂ©ron9a624912002-05-31 23:06:46 +00001/* Unit test suite for SHReg* functions
Juergen Schmiedc74a7912002-05-09 19:48:07 +00002 *
3 * Copyright 2002 Juergen Schmied
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <assert.h>
Alexandre Julliarde37c6e12003-09-05 23:08:26 +000021#include <stdarg.h>
Juergen Schmiedc74a7912002-05-09 19:48:07 +000022#include <stdio.h>
23
24#include "wine/test.h"
Alexandre Julliarde37c6e12003-09-05 23:08:26 +000025#include "windef.h"
Juergen Schmiedc74a7912002-05-09 19:48:07 +000026#include "winbase.h"
Francois Gouget4c314002002-05-23 02:40:07 +000027#include "winerror.h"
Juergen Schmiedc74a7912002-05-09 19:48:07 +000028#include "winreg.h"
29#include "winuser.h"
Juergen Schmiedc74a7912002-05-09 19:48:07 +000030#include "shlwapi.h"
31
Patrik Stridvall7e252cb2002-09-12 20:45:22 +000032/* Keys used for testing */
Jon Griffithsf5b34b52002-09-12 18:02:14 +000033#define REG_TEST_KEY "Software\\Wine\\Test"
Paul Vriens361ee292005-01-17 15:45:44 +000034#define REG_CURRENT_VERSION "Software\\Microsoft\\Windows\\CurrentVersion"
Jon Griffithsf5b34b52002-09-12 18:02:14 +000035
Francois Gouget3a860192002-09-16 22:45:22 +000036static HMODULE hshlwapi;
37typedef DWORD (WINAPI *SHCopyKeyA_func)(HKEY,LPCSTR,HKEY,DWORD);
38static SHCopyKeyA_func pSHCopyKeyA;
39typedef DWORD (WINAPI *SHRegGetPathA_func)(HKEY,LPCSTR,LPCSTR,LPSTR,DWORD);
40static SHRegGetPathA_func pSHRegGetPathA;
41
Daniel Marmier7e0ddbc2003-10-07 22:54:17 +000042static const char * sTestpath1 = "%LONGSYSTEMVAR%\\subdir1";
43static const char * sTestpath2 = "%FOO%\\subdir1";
Juergen Schmiedc74a7912002-05-09 19:48:07 +000044
Paul Vriensa3d0eeb2005-01-31 11:29:59 +000045static const char * sEnvvar1 = "bar";
46static const char * sEnvvar2 = "ImARatherLongButIndeedNeededString";
47
Juergen Schmiedc74a7912002-05-09 19:48:07 +000048static char sExpTestpath1[MAX_PATH];
49static char sExpTestpath2[MAX_PATH];
Eric Pouechf320e742002-06-28 17:35:20 +000050static unsigned sExpLen1;
51static unsigned sExpLen2;
Juergen Schmiedc74a7912002-05-09 19:48:07 +000052
Daniel Marmier7e0ddbc2003-10-07 22:54:17 +000053static const char * sEmptyBuffer ="0123456789";
Juergen Schmiedc74a7912002-05-09 19:48:07 +000054
Alexandre Julliard35079992002-09-12 22:29:58 +000055/* delete key and all its subkeys */
James Hawkins0fec65d2004-11-10 01:30:59 +000056static DWORD delete_key( HKEY hkey, LPSTR parent, LPSTR keyname )
Alexandre Julliard35079992002-09-12 22:29:58 +000057{
James Hawkins0fec65d2004-11-10 01:30:59 +000058 HKEY parentKey;
Alexandre Julliard35079992002-09-12 22:29:58 +000059 DWORD ret;
60
James Hawkins0fec65d2004-11-10 01:30:59 +000061 RegCloseKey(hkey);
62
63 /* open the parent of the key to close */
Jon Griffiths1f79d572004-12-15 10:50:01 +000064 ret = RegOpenKeyExA( HKEY_CURRENT_USER, parent, 0, KEY_ALL_ACCESS, &parentKey);
James Hawkins0fec65d2004-11-10 01:30:59 +000065 if (ret != ERROR_SUCCESS)
66 return ret;
67
Jon Griffiths1f79d572004-12-15 10:50:01 +000068 ret = SHDeleteKeyA( parentKey, keyname );
James Hawkins0fec65d2004-11-10 01:30:59 +000069 RegCloseKey(parentKey);
70
71 return ret;
Alexandre Julliard35079992002-09-12 22:29:58 +000072}
73
74static HKEY create_test_entries(void)
Juergen Schmiedc74a7912002-05-09 19:48:07 +000075{
76 HKEY hKey;
Paul Vriens14b96352005-01-21 16:18:00 +000077 DWORD ret;
Juergen Schmiedc74a7912002-05-09 19:48:07 +000078
Paul Vriensa3d0eeb2005-01-31 11:29:59 +000079 SetEnvironmentVariableA("LONGSYSTEMVAR", sEnvvar1);
80 SetEnvironmentVariableA("FOO", sEnvvar2);
Eric Pouechf320e742002-06-28 17:35:20 +000081
Paul Vriens14b96352005-01-21 16:18:00 +000082 ret = RegCreateKeyA(HKEY_CURRENT_USER, REG_TEST_KEY, &hKey);
83 ok( ERROR_SUCCESS == ret, "RegCreateKeyA failed, ret=%lu\n", ret);
Juergen Schmiedc74a7912002-05-09 19:48:07 +000084
85 if (hKey)
86 {
Francois Gougetce7c3b52004-01-27 20:13:03 +000087 ok(!RegSetValueExA(hKey,"Test1",0,REG_EXPAND_SZ, sTestpath1, strlen(sTestpath1)+1), "RegSetValueExA failed\n");
88 ok(!RegSetValueExA(hKey,"Test2",0,REG_SZ, sTestpath1, strlen(sTestpath1)+1), "RegSetValueExA failed\n");
89 ok(!RegSetValueExA(hKey,"Test3",0,REG_EXPAND_SZ, sTestpath2, strlen(sTestpath2)+1), "RegSetValueExA failed\n");
Juergen Schmiedc74a7912002-05-09 19:48:07 +000090 }
91
Eric Pouechf320e742002-06-28 17:35:20 +000092 sExpLen1 = ExpandEnvironmentStringsA(sTestpath1, sExpTestpath1, sizeof(sExpTestpath1));
93 sExpLen2 = ExpandEnvironmentStringsA(sTestpath2, sExpTestpath2, sizeof(sExpTestpath2));
94
95 ok(sExpLen1 > 0, "Couldn't expand %s\n", sTestpath1);
Paul Vriens89330702005-02-03 19:38:58 +000096 trace("sExplen1 = (%d)\n", sExpLen1);
Eric Pouechf320e742002-06-28 17:35:20 +000097 ok(sExpLen2 > 0, "Couldn't expand %s\n", sTestpath2);
Paul Vriens89330702005-02-03 19:38:58 +000098 trace("sExplen2 = (%d)\n", sExpLen2);
99
Alexandre Julliard35079992002-09-12 22:29:58 +0000100 return hKey;
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000101}
102
103static void test_SHGetValue(void)
104{
105 DWORD dwSize;
106 DWORD dwType;
Paul Vriens14b96352005-01-21 16:18:00 +0000107 DWORD dwRet;
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000108 char buf[MAX_PATH];
109
110 strcpy(buf, sEmptyBuffer);
111 dwSize = MAX_PATH;
112 dwType = -1;
Paul Vriens14b96352005-01-21 16:18:00 +0000113 dwRet = SHGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", &dwType, buf, &dwSize);
114 ok( ERROR_SUCCESS == dwRet, "SHGetValueA failed, ret=%lu\n", dwRet);
115 ok( 0 == strcmp(sExpTestpath1, buf), "Comparing of (%s) with (%s) failed\n", buf, sExpTestpath1);
116 ok( REG_SZ == dwType, "Expected REG_SZ, got (%lu)\n", dwType);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000117
118 strcpy(buf, sEmptyBuffer);
119 dwSize = MAX_PATH;
120 dwType = -1;
Paul Vriens14b96352005-01-21 16:18:00 +0000121 dwRet = SHGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", &dwType, buf, &dwSize);
122 ok( ERROR_SUCCESS == dwRet, "SHGetValueA failed, ret=%lu\n", dwRet);
123 ok( 0 == strcmp(sTestpath1, buf) , "Comparing of (%s) with (%s) failed\n", buf, sTestpath1);
124 ok( REG_SZ == dwType , "Expected REG_SZ, got (%lu)\n", dwType);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000125}
126
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000127static void test_SHGetRegPath(void)
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000128{
129 char buf[MAX_PATH];
Paul Vriens14b96352005-01-21 16:18:00 +0000130 DWORD dwRet;
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000131
Francois Gouget3a860192002-09-16 22:45:22 +0000132 if (!pSHRegGetPathA)
133 return;
134
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000135 strcpy(buf, sEmptyBuffer);
Paul Vriens14b96352005-01-21 16:18:00 +0000136 dwRet = (*pSHRegGetPathA)(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", buf, 0);
137 ok( ERROR_SUCCESS == dwRet, "SHRegGetPathA failed, ret=%lu\n", dwRet);
138 ok( 0 == strcmp(sExpTestpath1, buf) , "Comparing (%s) with (%s) failed\n", buf, sExpTestpath1);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000139}
140
141static void test_SHQUeryValueEx(void)
142{
143 HKEY hKey;
144 DWORD dwSize;
145 DWORD dwType;
146 char buf[MAX_PATH];
147 DWORD dwRet;
Daniel Marmier7e0ddbc2003-10-07 22:54:17 +0000148 const char * sTestedFunction = "";
Francois Gouget23aa0f62002-12-18 20:50:49 +0000149 DWORD nUsedBuffer1,nUsedBuffer2;
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000150
Paul Vriens14b96352005-01-21 16:18:00 +0000151 sTestedFunction = "RegOpenKeyExA";
152 dwRet = RegOpenKeyExA(HKEY_CURRENT_USER, REG_TEST_KEY, 0, KEY_QUERY_VALUE, &hKey);
153 ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%lu\n", sTestedFunction, dwRet);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000154
155 /****** SHQueryValueExA ******/
156
157 sTestedFunction = "SHQueryValueExA";
Alexandre Julliard63d29eb2002-08-09 01:14:23 +0000158 nUsedBuffer1 = max(strlen(sExpTestpath1)+1, strlen(sTestpath1)+1);
159 nUsedBuffer2 = max(strlen(sExpTestpath2)+1, strlen(sTestpath2)+1);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000160 /*
161 * Case 1.1 All arguments are NULL
162 */
Paul Vriens14b96352005-01-21 16:18:00 +0000163 dwRet = SHQueryValueExA( hKey, "Test1", NULL, NULL, NULL, NULL);
164 ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%lu\n", sTestedFunction, dwRet);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000165
166 /*
167 * Case 1.2 dwType is set
168 */
169 dwType = -1;
Paul Vriens14b96352005-01-21 16:18:00 +0000170 dwRet = SHQueryValueExA( hKey, "Test1", NULL, &dwType, NULL, NULL);
171 ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%lu\n", sTestedFunction, dwRet);
172 ok( REG_SZ == dwType , "Expected REG_SZ, got (%lu)\n", dwType);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000173
174 /*
175 * dwSize is set
176 * dwExpanded < dwUnExpanded
177 */
178 dwSize = 6;
Paul Vriens14b96352005-01-21 16:18:00 +0000179 dwRet = SHQueryValueExA( hKey, "Test1", NULL, NULL, NULL, &dwSize);
180 ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%lu\n", sTestedFunction, dwRet);
181 ok( dwSize == nUsedBuffer1, "Buffer sizes (%lu) and (%lu) are not equal\n", dwSize, nUsedBuffer1);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000182
183 /*
184 * dwExpanded > dwUnExpanded
185 */
186 dwSize = 6;
Paul Vriens14b96352005-01-21 16:18:00 +0000187 dwRet = SHQueryValueExA( hKey, "Test3", NULL, NULL, NULL, &dwSize);
188 ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%lu\n", sTestedFunction, dwRet);
189 ok( dwSize >= nUsedBuffer2, "Buffer size (%lu) should be >= (%lu)\n", dwSize, nUsedBuffer2);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000190
191 /*
192 * Case 1 string shrinks during expanding
193 */
194 strcpy(buf, sEmptyBuffer);
195 dwSize = 6;
196 dwType = -1;
197 dwRet = SHQueryValueExA( hKey, "Test1", NULL, &dwType, buf, &dwSize);
Paul Vriens14b96352005-01-21 16:18:00 +0000198 ok( ERROR_MORE_DATA == dwRet, "Expected ERROR_MORE_DATA, got (%lu)\n", dwRet);
199 ok( 0 == strcmp(sEmptyBuffer, buf) , "Comparing (%s) with (%s) failed\n", buf, sEmptyBuffer);
200 ok( dwSize == nUsedBuffer1, "Buffer sizes (%lu) and (%lu) are not equal\n", dwSize, nUsedBuffer1);
201 ok( REG_SZ == dwType , "Expected REG_SZ, got (%lu)\n", dwType);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000202
203 /*
204 * string grows during expanding
Paul Vriensa3d0eeb2005-01-31 11:29:59 +0000205 * dwSize is smaller then the size of the unexpanded string
Vincent BĂ©ron9a624912002-05-31 23:06:46 +0000206 */
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000207 strcpy(buf, sEmptyBuffer);
208 dwSize = 6;
209 dwType = -1;
210 dwRet = SHQueryValueExA( hKey, "Test3", NULL, &dwType, buf, &dwSize);
Paul Vriens14b96352005-01-21 16:18:00 +0000211 ok( ERROR_MORE_DATA == dwRet, "Expected ERROR_MORE_DATA, got (%lu)\n", dwRet);
212 ok( 0 == strcmp(sEmptyBuffer, buf) , "Comparing (%s) with (%s) failed\n", buf, sEmptyBuffer);
213 ok( dwSize >= nUsedBuffer2, "Buffer size (%lu) should be >= (%lu)\n", dwSize, nUsedBuffer2);
214 ok( REG_SZ == dwType , "Expected REG_SZ, got (%lu)\n", dwType);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000215
Paul Vriensa3d0eeb2005-01-31 11:29:59 +0000216 /*
217 * string grows during expanding
218 * dwSize is larger then the size of the unexpanded string but smaller than the part before the backslash
219 * if the unexpanded string fits into the buffer it can get cut when expanded
220 */
221 strcpy(buf, sEmptyBuffer);
222 dwSize = strlen(sEnvvar2) - 2;
223 dwType = -1;
224 dwRet = SHQueryValueExA( hKey, "Test3", NULL, &dwType, buf, &dwSize);
225 ok( ERROR_MORE_DATA == dwRet, "Expected ERROR_MORE_DATA, got (%lu)\n", dwRet);
226
227 todo_wine
228 {
229 ok( (0 == strcmp("", buf)) | (0 == strcmp(sTestpath2, buf)),
230 "Expected empty or unexpanded string (win98), got (%s)\n", buf);
231 }
232
233 ok( dwSize >= nUsedBuffer2, "Buffer size (%lu) should be >= (%lu)\n", dwSize, nUsedBuffer2);
234 ok( REG_SZ == dwType , "Expected REG_SZ, got (%lu)\n", dwType);
235
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000236 /*
Paul Vriensa3d0eeb2005-01-31 11:29:59 +0000237 * string grows during expanding
238 * dwSize is larger then the size of the part before the backslash but smaller then the expanded string
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000239 * if the unexpanded string fits into the buffer it can get cut when expanded
240 */
241 strcpy(buf, sEmptyBuffer);
Eric Pouechf320e742002-06-28 17:35:20 +0000242 dwSize = sExpLen2 - 4;
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000243 dwType = -1;
Paul Vriens14b96352005-01-21 16:18:00 +0000244 dwRet = SHQueryValueExA( hKey, "Test3", NULL, &dwType, buf, &dwSize);
245 ok( ERROR_MORE_DATA == dwRet, "Expected ERROR_MORE_DATA, got (%lu)\n", dwRet);
Paul Vriensa3d0eeb2005-01-31 11:29:59 +0000246
247 todo_wine
248 {
249 ok( (0 == strcmp("", buf)) | (0 == strcmp(sEnvvar2, buf)),
Jakob Erikssona4fe0d62005-03-22 18:18:14 +0000250 "Expected empty or first part of the string \"%s\", got \"%s\"\n", sEnvvar2, buf);
Paul Vriensa3d0eeb2005-01-31 11:29:59 +0000251 }
252
Paul Vriens14b96352005-01-21 16:18:00 +0000253 ok( dwSize >= nUsedBuffer2, "Buffer size (%lu) should be >= (%lu)\n", dwSize, nUsedBuffer2);
254 ok( REG_SZ == dwType , "Expected REG_SZ, got (%lu)\n", dwType);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000255
256 /*
257 * The buffer is NULL but the size is set
258 */
259 strcpy(buf, sEmptyBuffer);
260 dwSize = 6;
261 dwType = -1;
262 dwRet = SHQueryValueExA( hKey, "Test3", NULL, &dwType, NULL, &dwSize);
Paul Vriens14b96352005-01-21 16:18:00 +0000263 ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%lu\n", sTestedFunction, dwRet);
264 ok( dwSize >= nUsedBuffer2, "Buffer size (%lu) should be >= (%lu)\n", dwSize, nUsedBuffer2);
265 ok( REG_SZ == dwType , "Expected REG_SZ, got (%lu)\n", dwType);
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000266
267 RegCloseKey(hKey);
268}
269
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000270static void test_SHCopyKey(void)
271{
272 HKEY hKeySrc, hKeyDst;
Paul Vriens89330702005-02-03 19:38:58 +0000273 DWORD dwRet;
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000274
Patrik Stridvall7e252cb2002-09-12 20:45:22 +0000275 /* Delete existing destination sub keys */
Francois Gougetd2667a42002-12-02 18:10:57 +0000276 hKeyDst = NULL;
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000277 if (!RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\CopyDestination", &hKeyDst) && hKeyDst)
278 {
279 SHDeleteKeyA(hKeyDst, NULL);
280 RegCloseKey(hKeyDst);
281 }
282
Francois Gougetd2667a42002-12-02 18:10:57 +0000283 hKeyDst = NULL;
Paul Vriens89330702005-02-03 19:38:58 +0000284 dwRet = RegCreateKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\CopyDestination", &hKeyDst);
285 if (dwRet || !hKeyDst)
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000286 {
Paul Vriens89330702005-02-03 19:38:58 +0000287 ok( 0, "Destination couldn't be created, RegCreateKeyA returned (%lu)\n", dwRet);
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000288 return;
289 }
290
Francois Gougetd2667a42002-12-02 18:10:57 +0000291 hKeySrc = NULL;
Paul Vriens89330702005-02-03 19:38:58 +0000292 dwRet = RegOpenKeyA(HKEY_LOCAL_MACHINE, REG_CURRENT_VERSION, &hKeySrc);
293 if (dwRet || !hKeySrc)
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000294 {
Paul Vriens89330702005-02-03 19:38:58 +0000295 ok( 0, "Source couldn't be opened, RegOpenKeyA returned (%lu)\n", dwRet);
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000296 return;
297 }
298
299
Francois Gouget3a860192002-09-16 22:45:22 +0000300 if (pSHCopyKeyA)
Paul Vriens89330702005-02-03 19:38:58 +0000301 {
302 dwRet = (*pSHCopyKeyA)(hKeySrc, NULL, hKeyDst, 0);
303 ok ( ERROR_SUCCESS == dwRet, "Copy failed, ret=(%lu)\n", dwRet);
304 }
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000305
306 RegCloseKey(hKeySrc);
307 RegCloseKey(hKeyDst);
308
Paul Vriens361ee292005-01-17 15:45:44 +0000309 /* Check we copied the sub keys, i.e. something that's on every windows system (including Wine) */
Francois Gougetd2667a42002-12-02 18:10:57 +0000310 hKeyDst = NULL;
Paul Vriens89330702005-02-03 19:38:58 +0000311 dwRet = RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\CopyDestination\\Setup", &hKeyDst);
312 if (dwRet || !hKeyDst)
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000313 {
Paul Vriens89330702005-02-03 19:38:58 +0000314 ok ( 0, "Copy couldn't be opened, RegOpenKeyA returned (%lu)\n", dwRet);
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000315 return;
316 }
317
318 /* And the we copied the values too */
Paul Vriens361ee292005-01-17 15:45:44 +0000319 ok(!SHQueryValueExA(hKeyDst, "BootDir", NULL, NULL, NULL, NULL), "SHQueryValueExA failed\n");
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000320
321 RegCloseKey(hKeyDst);
322}
323
Stefan Huehnerac6f5622005-06-20 14:18:03 +0000324static void test_SHDeleteKey(void)
Bill Medland3f3e2922004-10-14 00:25:29 +0000325{
Paul Vriens89330702005-02-03 19:38:58 +0000326 HKEY hKeyTest, hKeyS;
327 DWORD dwRet;
328 int sysfail = 1;
329
Bill Medland3f3e2922004-10-14 00:25:29 +0000330 if (!RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_KEY, &hKeyTest))
331 {
Bill Medland3f3e2922004-10-14 00:25:29 +0000332 if (!RegCreateKey(hKeyTest, "ODBC", &hKeyS))
333 {
334 HKEY hKeyO;
Paul Vriens89330702005-02-03 19:38:58 +0000335
Bill Medland3f3e2922004-10-14 00:25:29 +0000336 if (!RegCreateKey(hKeyS, "ODBC.INI", &hKeyO))
337 {
338 RegCloseKey (hKeyO);
Paul Vriens89330702005-02-03 19:38:58 +0000339
Bill Medland3f3e2922004-10-14 00:25:29 +0000340 if (!RegCreateKey(hKeyS, "ODBCINST.INI", &hKeyO))
341 {
342 RegCloseKey (hKeyO);
343 sysfail = 0;
344 }
345 }
346 RegCloseKey (hKeyS);
347 }
348 RegCloseKey (hKeyTest);
349 }
Paul Vriens89330702005-02-03 19:38:58 +0000350
Bill Medland3f3e2922004-10-14 00:25:29 +0000351 if (!sysfail)
352 {
Paul Vriens89330702005-02-03 19:38:58 +0000353
354 dwRet = SHDeleteKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\ODBC");
355 ok ( ERROR_SUCCESS == dwRet, "SHDeleteKey failed, ret=(%lu)\n", dwRet);
356
357 dwRet = RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\ODBC", &hKeyS);
358 ok ( ERROR_FILE_NOT_FOUND == dwRet, "SHDeleteKey did not delete\n");
359
Bill Medland3f3e2922004-10-14 00:25:29 +0000360 if (dwRet == ERROR_SUCCESS)
361 RegCloseKey (hKeyS);
362 }
363 else
Paul Vriens89330702005-02-03 19:38:58 +0000364 ok( 0, "Could not set up SHDeleteKey test\n");
Bill Medland3f3e2922004-10-14 00:25:29 +0000365}
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000366
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000367START_TEST(shreg)
368{
Alexandre Julliard35079992002-09-12 22:29:58 +0000369 HKEY hkey = create_test_entries();
Paul Vriens14b96352005-01-21 16:18:00 +0000370
371 if (!hkey) return;
372
Francois Gouget3a860192002-09-16 22:45:22 +0000373 hshlwapi = GetModuleHandleA("shlwapi.dll");
374 if (hshlwapi)
375 {
376 pSHCopyKeyA=(SHCopyKeyA_func)GetProcAddress(hshlwapi,"SHCopyKeyA");
377 pSHRegGetPathA=(SHRegGetPathA_func)GetProcAddress(hshlwapi,"SHRegGetPathA");
378 }
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000379 test_SHGetValue();
380 test_SHQUeryValueEx();
Jon Griffithsf5b34b52002-09-12 18:02:14 +0000381 test_SHGetRegPath();
382 test_SHCopyKey();
Bill Medland3f3e2922004-10-14 00:25:29 +0000383 test_SHDeleteKey();
James Hawkins0fec65d2004-11-10 01:30:59 +0000384 delete_key( hkey, "Software\\Wine", "Test" );
Juergen Schmiedc74a7912002-05-09 19:48:07 +0000385}