2002-06-01 01:06:46 +02:00
|
|
|
/* Unit test suite for SHReg* functions
|
2002-05-09 21:48:07 +02:00
|
|
|
*
|
|
|
|
* Copyright 2002 Juergen Schmied
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-05-09 21:48:07 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-05-09 21:48:07 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-05-09 21:48:07 +02:00
|
|
|
#include "winbase.h"
|
2002-05-23 04:40:07 +02:00
|
|
|
#include "winerror.h"
|
2002-05-09 21:48:07 +02:00
|
|
|
#include "winreg.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
2002-09-12 22:45:22 +02:00
|
|
|
/* Keys used for testing */
|
2002-09-12 20:02:14 +02:00
|
|
|
#define REG_TEST_KEY "Software\\Wine\\Test"
|
2008-12-17 10:46:49 +01:00
|
|
|
#define REG_CURRENT_VERSION "Software\\Microsoft\\Windows\\CurrentVersion\\explorer"
|
2002-09-12 20:02:14 +02:00
|
|
|
|
2002-09-17 00:45:22 +02:00
|
|
|
static HMODULE hshlwapi;
|
2011-12-01 18:19:29 +01:00
|
|
|
|
|
|
|
static DWORD (WINAPI *pSHCopyKeyA)(HKEY,LPCSTR,HKEY,DWORD);
|
|
|
|
static DWORD (WINAPI *pSHRegGetPathA)(HKEY,LPCSTR,LPCSTR,LPSTR,DWORD);
|
|
|
|
static LSTATUS (WINAPI *pSHRegGetValueA)(HKEY,LPCSTR,LPCSTR,SRRF,LPDWORD,LPVOID,LPDWORD);
|
|
|
|
static LSTATUS (WINAPI *pSHRegCreateUSKeyW)(LPCWSTR,REGSAM,HUSKEY,PHUSKEY,DWORD);
|
2002-09-17 00:45:22 +02:00
|
|
|
|
2013-12-28 14:14:58 +01:00
|
|
|
static const char sTestpath1[] = "%LONGSYSTEMVAR%\\subdir1";
|
|
|
|
static const char sTestpath2[] = "%FOO%\\subdir1";
|
2002-05-09 21:48:07 +02:00
|
|
|
|
2005-01-31 12:29:59 +01:00
|
|
|
static const char * sEnvvar1 = "bar";
|
|
|
|
static const char * sEnvvar2 = "ImARatherLongButIndeedNeededString";
|
|
|
|
|
2002-05-09 21:48:07 +02:00
|
|
|
static char sExpTestpath1[MAX_PATH];
|
|
|
|
static char sExpTestpath2[MAX_PATH];
|
2005-08-12 17:51:22 +02:00
|
|
|
static DWORD nExpLen1;
|
|
|
|
static DWORD nExpLen2;
|
2002-05-09 21:48:07 +02:00
|
|
|
|
2003-10-08 00:54:17 +02:00
|
|
|
static const char * sEmptyBuffer ="0123456789";
|
2002-05-09 21:48:07 +02:00
|
|
|
|
2002-09-13 00:29:58 +02:00
|
|
|
/* delete key and all its subkeys */
|
2006-08-08 22:01:38 +02:00
|
|
|
static DWORD delete_key( HKEY hkey, LPCSTR parent, LPCSTR keyname )
|
2002-09-13 00:29:58 +02:00
|
|
|
{
|
2004-11-10 02:30:59 +01:00
|
|
|
HKEY parentKey;
|
2002-09-13 00:29:58 +02:00
|
|
|
DWORD ret;
|
|
|
|
|
2004-11-10 02:30:59 +01:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
/* open the parent of the key to close */
|
2004-12-15 11:50:01 +01:00
|
|
|
ret = RegOpenKeyExA( HKEY_CURRENT_USER, parent, 0, KEY_ALL_ACCESS, &parentKey);
|
2004-11-10 02:30:59 +01:00
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
return ret;
|
|
|
|
|
2004-12-15 11:50:01 +01:00
|
|
|
ret = SHDeleteKeyA( parentKey, keyname );
|
2004-11-10 02:30:59 +01:00
|
|
|
RegCloseKey(parentKey);
|
|
|
|
|
|
|
|
return ret;
|
2002-09-13 00:29:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HKEY create_test_entries(void)
|
2002-05-09 21:48:07 +02:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
2005-01-21 17:18:00 +01:00
|
|
|
DWORD ret;
|
2005-08-12 17:51:22 +02:00
|
|
|
DWORD nExpectedLen1, nExpectedLen2;
|
2002-05-09 21:48:07 +02:00
|
|
|
|
2005-01-31 12:29:59 +01:00
|
|
|
SetEnvironmentVariableA("LONGSYSTEMVAR", sEnvvar1);
|
|
|
|
SetEnvironmentVariableA("FOO", sEnvvar2);
|
2002-06-28 19:35:20 +02:00
|
|
|
|
2005-01-21 17:18:00 +01:00
|
|
|
ret = RegCreateKeyA(HKEY_CURRENT_USER, REG_TEST_KEY, &hKey);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == ret, "RegCreateKeyA failed, ret=%u\n", ret);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
if (hKey)
|
|
|
|
{
|
2005-07-29 16:15:31 +02:00
|
|
|
ok(!RegSetValueExA(hKey,"Test1",0,REG_EXPAND_SZ, (LPBYTE) sTestpath1, strlen(sTestpath1)+1), "RegSetValueExA failed\n");
|
|
|
|
ok(!RegSetValueExA(hKey,"Test2",0,REG_SZ, (LPBYTE) sTestpath1, strlen(sTestpath1)+1), "RegSetValueExA failed\n");
|
|
|
|
ok(!RegSetValueExA(hKey,"Test3",0,REG_EXPAND_SZ, (LPBYTE) sTestpath2, strlen(sTestpath2)+1), "RegSetValueExA failed\n");
|
2002-05-09 21:48:07 +02:00
|
|
|
}
|
|
|
|
|
2005-08-12 17:51:22 +02:00
|
|
|
nExpLen1 = ExpandEnvironmentStringsA(sTestpath1, sExpTestpath1, sizeof(sExpTestpath1));
|
|
|
|
nExpLen2 = ExpandEnvironmentStringsA(sTestpath2, sExpTestpath2, sizeof(sExpTestpath2));
|
2002-06-28 19:35:20 +02:00
|
|
|
|
2005-08-12 17:51:22 +02:00
|
|
|
nExpectedLen1 = strlen(sTestpath1) - strlen("%LONGSYSTEMVAR%") + strlen(sEnvvar1) + 1;
|
|
|
|
nExpectedLen2 = strlen(sTestpath2) - strlen("%FOO%") + strlen(sEnvvar2) + 1;
|
|
|
|
/* ExpandEnvironmentStringsA on NT4 returns 2x the correct result */
|
2006-10-06 12:43:34 +02:00
|
|
|
trace("sExplen1 = (%d)\n", nExpLen1);
|
2005-08-12 17:51:22 +02:00
|
|
|
if (nExpectedLen1 != nExpLen1)
|
2006-10-06 12:43:34 +02:00
|
|
|
trace( "Expanding %s failed (expected %d) - known bug in NT4\n", sTestpath1, nExpectedLen1 );
|
2005-02-03 20:38:58 +01:00
|
|
|
|
2006-10-06 12:43:34 +02:00
|
|
|
trace("sExplen2 = (%d)\n", nExpLen2);
|
2005-08-12 17:51:22 +02:00
|
|
|
if (nExpectedLen2 != nExpLen2)
|
2006-10-06 12:43:34 +02:00
|
|
|
trace( "Expanding %s failed (expected %d) - known bug in NT4\n", sTestpath2, nExpectedLen2 );
|
2005-08-12 17:51:22 +02:00
|
|
|
|
|
|
|
/* Make sure we carry on with correct values */
|
|
|
|
nExpLen1 = nExpectedLen1;
|
|
|
|
nExpLen2 = nExpectedLen2;
|
|
|
|
return hKey;
|
2002-05-09 21:48:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SHGetValue(void)
|
|
|
|
{
|
|
|
|
DWORD dwSize;
|
|
|
|
DWORD dwType;
|
2005-01-21 17:18:00 +01:00
|
|
|
DWORD dwRet;
|
2002-05-09 21:48:07 +02:00
|
|
|
char buf[MAX_PATH];
|
|
|
|
|
|
|
|
strcpy(buf, sEmptyBuffer);
|
|
|
|
dwSize = MAX_PATH;
|
|
|
|
dwType = -1;
|
2005-01-21 17:18:00 +01:00
|
|
|
dwRet = SHGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", &dwType, buf, &dwSize);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == dwRet, "SHGetValueA failed, ret=%u\n", dwRet);
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( 0 == strcmp(sExpTestpath1, buf) ||
|
|
|
|
broken(0 == strcmp(sTestpath1, buf)), /* IE4.x */
|
|
|
|
"Comparing of (%s) with (%s) failed\n", buf, sExpTestpath1);
|
|
|
|
ok( REG_SZ == dwType ||
|
|
|
|
broken(REG_EXPAND_SZ == dwType), /* IE4.x */
|
|
|
|
"Expected REG_SZ, got (%u)\n", dwType);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
strcpy(buf, sEmptyBuffer);
|
|
|
|
dwSize = MAX_PATH;
|
|
|
|
dwType = -1;
|
2005-01-21 17:18:00 +01:00
|
|
|
dwRet = SHGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", &dwType, buf, &dwSize);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == dwRet, "SHGetValueA failed, ret=%u\n", dwRet);
|
2005-01-21 17:18:00 +01:00
|
|
|
ok( 0 == strcmp(sTestpath1, buf) , "Comparing of (%s) with (%s) failed\n", buf, sTestpath1);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( REG_SZ == dwType , "Expected REG_SZ, got (%u)\n", dwType);
|
2002-05-09 21:48:07 +02:00
|
|
|
}
|
|
|
|
|
2010-01-31 23:03:09 +01:00
|
|
|
static void test_SHRegGetValue(void)
|
|
|
|
{
|
|
|
|
LSTATUS ret;
|
|
|
|
DWORD size, type;
|
|
|
|
char data[MAX_PATH];
|
|
|
|
|
|
|
|
if(!pSHRegGetValueA)
|
|
|
|
return;
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", SRRF_RT_REG_EXPAND_SZ, &type, data, &size);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "SHRegGetValue failed, ret=%u\n", ret);
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", SRRF_RT_REG_SZ, &type, data, &size);
|
|
|
|
ok(ret == ERROR_SUCCESS, "SHRegGetValue failed, ret=%u\n", ret);
|
|
|
|
ok(!strcmp(data, sExpTestpath1), "data = %s, expected %s\n", data, sExpTestpath1);
|
|
|
|
ok(type == REG_SZ, "type = %d, expected REG_SZ\n", type);
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", SRRF_RT_REG_DWORD, &type, data, &size);
|
|
|
|
ok(ret == ERROR_UNSUPPORTED_TYPE, "SHRegGetValue failed, ret=%u\n", ret);
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", SRRF_RT_REG_EXPAND_SZ, &type, data, &size);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "SHRegGetValue failed, ret=%u\n", ret);
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", SRRF_RT_REG_SZ, &type, data, &size);
|
|
|
|
ok(ret == ERROR_SUCCESS, "SHRegGetValue failed, ret=%u\n", ret);
|
|
|
|
ok(!strcmp(data, sTestpath1), "data = %s, expected %s\n", data, sTestpath1);
|
|
|
|
ok(type == REG_SZ, "type = %d, expected REG_SZ\n", type);
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
ret = pSHRegGetValueA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test2", SRRF_RT_REG_QWORD, &type, data, &size);
|
|
|
|
ok(ret == ERROR_UNSUPPORTED_TYPE, "SHRegGetValue failed, ret=%u\n", ret);
|
|
|
|
}
|
|
|
|
|
2002-09-12 20:02:14 +02:00
|
|
|
static void test_SHGetRegPath(void)
|
2002-05-09 21:48:07 +02:00
|
|
|
{
|
|
|
|
char buf[MAX_PATH];
|
2005-01-21 17:18:00 +01:00
|
|
|
DWORD dwRet;
|
2002-05-09 21:48:07 +02:00
|
|
|
|
2002-09-17 00:45:22 +02:00
|
|
|
if (!pSHRegGetPathA)
|
|
|
|
return;
|
|
|
|
|
2002-05-09 21:48:07 +02:00
|
|
|
strcpy(buf, sEmptyBuffer);
|
2005-01-21 17:18:00 +01:00
|
|
|
dwRet = (*pSHRegGetPathA)(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", buf, 0);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == dwRet, "SHRegGetPathA failed, ret=%u\n", dwRet);
|
2005-01-21 17:18:00 +01:00
|
|
|
ok( 0 == strcmp(sExpTestpath1, buf) , "Comparing (%s) with (%s) failed\n", buf, sExpTestpath1);
|
2002-05-09 21:48:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-30 02:41:20 +01:00
|
|
|
static void test_SHQueryValueEx(void)
|
2002-05-09 21:48:07 +02:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
DWORD dwSize;
|
|
|
|
DWORD dwType;
|
|
|
|
char buf[MAX_PATH];
|
|
|
|
DWORD dwRet;
|
2003-10-08 00:54:17 +02:00
|
|
|
const char * sTestedFunction = "";
|
2002-12-18 21:50:49 +01:00
|
|
|
DWORD nUsedBuffer1,nUsedBuffer2;
|
2002-05-09 21:48:07 +02:00
|
|
|
|
2005-01-21 17:18:00 +01:00
|
|
|
sTestedFunction = "RegOpenKeyExA";
|
|
|
|
dwRet = RegOpenKeyExA(HKEY_CURRENT_USER, REG_TEST_KEY, 0, KEY_QUERY_VALUE, &hKey);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%u\n", sTestedFunction, dwRet);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
/****** SHQueryValueExA ******/
|
|
|
|
|
|
|
|
sTestedFunction = "SHQueryValueExA";
|
2002-08-09 03:14:23 +02:00
|
|
|
nUsedBuffer1 = max(strlen(sExpTestpath1)+1, strlen(sTestpath1)+1);
|
|
|
|
nUsedBuffer2 = max(strlen(sExpTestpath2)+1, strlen(sTestpath2)+1);
|
2002-05-09 21:48:07 +02:00
|
|
|
/*
|
|
|
|
* Case 1.1 All arguments are NULL
|
|
|
|
*/
|
2005-01-21 17:18:00 +01:00
|
|
|
dwRet = SHQueryValueExA( hKey, "Test1", NULL, NULL, NULL, NULL);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%u\n", sTestedFunction, dwRet);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Case 1.2 dwType is set
|
|
|
|
*/
|
|
|
|
dwType = -1;
|
2005-01-21 17:18:00 +01:00
|
|
|
dwRet = SHQueryValueExA( hKey, "Test1", NULL, &dwType, NULL, NULL);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%u\n", sTestedFunction, dwRet);
|
|
|
|
ok( REG_SZ == dwType , "Expected REG_SZ, got (%u)\n", dwType);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* dwSize is set
|
|
|
|
* dwExpanded < dwUnExpanded
|
|
|
|
*/
|
|
|
|
dwSize = 6;
|
2005-01-21 17:18:00 +01:00
|
|
|
dwRet = SHQueryValueExA( hKey, "Test1", NULL, NULL, NULL, &dwSize);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%u\n", sTestedFunction, dwRet);
|
|
|
|
ok( dwSize == nUsedBuffer1, "Buffer sizes (%u) and (%u) are not equal\n", dwSize, nUsedBuffer1);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* dwExpanded > dwUnExpanded
|
|
|
|
*/
|
|
|
|
dwSize = 6;
|
2005-01-21 17:18:00 +01:00
|
|
|
dwRet = SHQueryValueExA( hKey, "Test3", NULL, NULL, NULL, &dwSize);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%u\n", sTestedFunction, dwRet);
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( dwSize >= nUsedBuffer2 ||
|
|
|
|
broken(dwSize == (strlen(sTestpath2) + 1)), /* < IE4.x */
|
|
|
|
"Buffer size (%u) should be >= (%u)\n", dwSize, nUsedBuffer2);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Case 1 string shrinks during expanding
|
|
|
|
*/
|
|
|
|
strcpy(buf, sEmptyBuffer);
|
|
|
|
dwSize = 6;
|
|
|
|
dwType = -1;
|
|
|
|
dwRet = SHQueryValueExA( hKey, "Test1", NULL, &dwType, buf, &dwSize);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_MORE_DATA == dwRet, "Expected ERROR_MORE_DATA, got (%u)\n", dwRet);
|
2005-01-21 17:18:00 +01:00
|
|
|
ok( 0 == strcmp(sEmptyBuffer, buf) , "Comparing (%s) with (%s) failed\n", buf, sEmptyBuffer);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( dwSize == nUsedBuffer1, "Buffer sizes (%u) and (%u) are not equal\n", dwSize, nUsedBuffer1);
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( REG_SZ == dwType ||
|
|
|
|
broken(REG_EXPAND_SZ == dwType), /* < IE6 */
|
|
|
|
"Expected REG_SZ, got (%u)\n", dwType);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* string grows during expanding
|
2007-06-07 11:48:55 +02:00
|
|
|
* dwSize is smaller than the size of the unexpanded string
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
2002-05-09 21:48:07 +02:00
|
|
|
strcpy(buf, sEmptyBuffer);
|
|
|
|
dwSize = 6;
|
|
|
|
dwType = -1;
|
|
|
|
dwRet = SHQueryValueExA( hKey, "Test3", NULL, &dwType, buf, &dwSize);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_MORE_DATA == dwRet, "Expected ERROR_MORE_DATA, got (%u)\n", dwRet);
|
2005-01-21 17:18:00 +01:00
|
|
|
ok( 0 == strcmp(sEmptyBuffer, buf) , "Comparing (%s) with (%s) failed\n", buf, sEmptyBuffer);
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( dwSize >= nUsedBuffer2 ||
|
|
|
|
broken(dwSize == (strlen(sTestpath2) + 1)), /* < IE6 */
|
|
|
|
"Buffer size (%u) should be >= (%u)\n", dwSize, nUsedBuffer2);
|
|
|
|
ok( REG_SZ == dwType ||
|
|
|
|
broken(REG_EXPAND_SZ == dwType), /* < IE6 */
|
|
|
|
"Expected REG_SZ, got (%u)\n", dwType);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
2005-01-31 12:29:59 +01:00
|
|
|
/*
|
|
|
|
* string grows during expanding
|
2007-06-07 11:48:55 +02:00
|
|
|
* dwSize is larger than the size of the unexpanded string, but
|
|
|
|
* smaller than the part before the backslash. If the unexpanded
|
|
|
|
* string fits into the buffer, it can get cut when expanded.
|
2005-01-31 12:29:59 +01:00
|
|
|
*/
|
|
|
|
strcpy(buf, sEmptyBuffer);
|
|
|
|
dwSize = strlen(sEnvvar2) - 2;
|
|
|
|
dwType = -1;
|
|
|
|
dwRet = SHQueryValueExA( hKey, "Test3", NULL, &dwType, buf, &dwSize);
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( ERROR_MORE_DATA == dwRet ||
|
|
|
|
broken(ERROR_ENVVAR_NOT_FOUND == dwRet) || /* IE5.5 */
|
|
|
|
broken(ERROR_SUCCESS == dwRet), /* < IE5.5*/
|
|
|
|
"Expected ERROR_MORE_DATA, got (%u)\n", dwRet);
|
2005-01-31 12:29:59 +01:00
|
|
|
|
|
|
|
todo_wine
|
|
|
|
{
|
2005-08-12 17:51:22 +02:00
|
|
|
ok( (0 == strcmp("", buf)) || (0 == strcmp(sTestpath2, buf)),
|
2005-01-31 12:29:59 +01:00
|
|
|
"Expected empty or unexpanded string (win98), got (%s)\n", buf);
|
|
|
|
}
|
|
|
|
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( dwSize >= nUsedBuffer2 ||
|
|
|
|
broken(dwSize == (strlen("") + 1)), /* < IE 5.5 */
|
|
|
|
"Buffer size (%u) should be >= (%u)\n", dwSize, nUsedBuffer2);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( REG_SZ == dwType , "Expected REG_SZ, got (%u)\n", dwType);
|
2005-01-31 12:29:59 +01:00
|
|
|
|
2002-05-09 21:48:07 +02:00
|
|
|
/*
|
2005-01-31 12:29:59 +01:00
|
|
|
* string grows during expanding
|
2007-06-07 11:48:55 +02:00
|
|
|
* dwSize is larger than the size of the part before the backslash,
|
|
|
|
* but smaller than the expanded string. If the unexpanded string fits
|
|
|
|
* into the buffer, it can get cut when expanded.
|
2002-05-09 21:48:07 +02:00
|
|
|
*/
|
|
|
|
strcpy(buf, sEmptyBuffer);
|
2005-08-12 17:51:22 +02:00
|
|
|
dwSize = nExpLen2 - 4;
|
2002-05-09 21:48:07 +02:00
|
|
|
dwType = -1;
|
2005-01-21 17:18:00 +01:00
|
|
|
dwRet = SHQueryValueExA( hKey, "Test3", NULL, &dwType, buf, &dwSize);
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( ERROR_MORE_DATA == dwRet ||
|
|
|
|
broken(ERROR_ENVVAR_NOT_FOUND == dwRet) || /* IE5.5 */
|
|
|
|
broken(ERROR_SUCCESS == dwRet), /* < IE5.5 */
|
|
|
|
"Expected ERROR_MORE_DATA, got (%u)\n", dwRet);
|
2005-01-31 12:29:59 +01:00
|
|
|
|
|
|
|
todo_wine
|
|
|
|
{
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( (0 == strcmp("", buf)) || (0 == strcmp(sEnvvar2, buf)) ||
|
|
|
|
broken(0 == strcmp(sTestpath2, buf)), /* IE 5.5 */
|
|
|
|
"Expected empty or first part of the string \"%s\", got \"%s\"\n", sEnvvar2, buf);
|
2005-01-31 12:29:59 +01:00
|
|
|
}
|
|
|
|
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( dwSize >= nUsedBuffer2 ||
|
|
|
|
broken(dwSize == (strlen(sEnvvar2) + 1)) || /* IE4.01 SP1 (W98) and IE5 (W98SE) */
|
|
|
|
broken(dwSize == (strlen("") + 1)), /* IE4.01 (NT4) and IE5.x (W2K) */
|
|
|
|
"Buffer size (%u) should be >= (%u)\n", dwSize, nUsedBuffer2);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( REG_SZ == dwType , "Expected REG_SZ, got (%u)\n", dwType);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The buffer is NULL but the size is set
|
|
|
|
*/
|
|
|
|
strcpy(buf, sEmptyBuffer);
|
|
|
|
dwSize = 6;
|
|
|
|
dwType = -1;
|
|
|
|
dwRet = SHQueryValueExA( hKey, "Test3", NULL, &dwType, NULL, &dwSize);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( ERROR_SUCCESS == dwRet, "%s failed, ret=%u\n", sTestedFunction, dwRet);
|
2009-03-09 11:20:35 +01:00
|
|
|
ok( dwSize >= nUsedBuffer2 ||
|
|
|
|
broken(dwSize == (strlen(sTestpath2) + 1)), /* IE4.01 SP1 (Win98) */
|
|
|
|
"Buffer size (%u) should be >= (%u)\n", dwSize, nUsedBuffer2);
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( REG_SZ == dwType , "Expected REG_SZ, got (%u)\n", dwType);
|
2002-05-09 21:48:07 +02:00
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
2002-09-12 20:02:14 +02:00
|
|
|
static void test_SHCopyKey(void)
|
|
|
|
{
|
|
|
|
HKEY hKeySrc, hKeyDst;
|
2005-02-03 20:38:58 +01:00
|
|
|
DWORD dwRet;
|
2002-09-12 20:02:14 +02:00
|
|
|
|
2008-12-17 10:46:49 +01:00
|
|
|
if (!pSHCopyKeyA)
|
|
|
|
{
|
|
|
|
win_skip("SHCopyKeyA is not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-12 22:45:22 +02:00
|
|
|
/* Delete existing destination sub keys */
|
2002-12-02 19:10:57 +01:00
|
|
|
hKeyDst = NULL;
|
2002-09-12 20:02:14 +02:00
|
|
|
if (!RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\CopyDestination", &hKeyDst) && hKeyDst)
|
|
|
|
{
|
|
|
|
SHDeleteKeyA(hKeyDst, NULL);
|
|
|
|
RegCloseKey(hKeyDst);
|
|
|
|
}
|
|
|
|
|
2002-12-02 19:10:57 +01:00
|
|
|
hKeyDst = NULL;
|
2005-02-03 20:38:58 +01:00
|
|
|
dwRet = RegCreateKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\CopyDestination", &hKeyDst);
|
|
|
|
if (dwRet || !hKeyDst)
|
2002-09-12 20:02:14 +02:00
|
|
|
{
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( 0, "Destination couldn't be created, RegCreateKeyA returned (%u)\n", dwRet);
|
2002-09-12 20:02:14 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-12-02 19:10:57 +01:00
|
|
|
hKeySrc = NULL;
|
2005-02-03 20:38:58 +01:00
|
|
|
dwRet = RegOpenKeyA(HKEY_LOCAL_MACHINE, REG_CURRENT_VERSION, &hKeySrc);
|
|
|
|
if (dwRet || !hKeySrc)
|
2002-09-12 20:02:14 +02:00
|
|
|
{
|
2006-10-06 12:43:34 +02:00
|
|
|
ok( 0, "Source couldn't be opened, RegOpenKeyA returned (%u)\n", dwRet);
|
2008-12-17 10:46:49 +01:00
|
|
|
RegCloseKey(hKeyDst);
|
2002-09-12 20:02:14 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-17 10:46:49 +01:00
|
|
|
dwRet = (*pSHCopyKeyA)(hKeySrc, NULL, hKeyDst, 0);
|
|
|
|
ok ( ERROR_SUCCESS == dwRet, "Copy failed, ret=(%u)\n", dwRet);
|
2002-09-12 20:02:14 +02:00
|
|
|
|
|
|
|
RegCloseKey(hKeySrc);
|
|
|
|
RegCloseKey(hKeyDst);
|
|
|
|
|
2005-01-17 16:45:44 +01:00
|
|
|
/* Check we copied the sub keys, i.e. something that's on every windows system (including Wine) */
|
2002-12-02 19:10:57 +01:00
|
|
|
hKeyDst = NULL;
|
2008-12-17 10:46:49 +01:00
|
|
|
dwRet = RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\CopyDestination\\Shell Folders", &hKeyDst);
|
2005-02-03 20:38:58 +01:00
|
|
|
if (dwRet || !hKeyDst)
|
2002-09-12 20:02:14 +02:00
|
|
|
{
|
2006-10-06 12:43:34 +02:00
|
|
|
ok ( 0, "Copy couldn't be opened, RegOpenKeyA returned (%u)\n", dwRet);
|
2002-09-12 20:02:14 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* And the we copied the values too */
|
2008-12-17 10:46:49 +01:00
|
|
|
ok(!SHQueryValueExA(hKeyDst, "Common AppData", NULL, NULL, NULL, NULL), "SHQueryValueExA failed\n");
|
2002-09-12 20:02:14 +02:00
|
|
|
|
|
|
|
RegCloseKey(hKeyDst);
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void test_SHDeleteKey(void)
|
2004-10-14 02:25:29 +02:00
|
|
|
{
|
2005-02-03 20:38:58 +01:00
|
|
|
HKEY hKeyTest, hKeyS;
|
|
|
|
DWORD dwRet;
|
|
|
|
int sysfail = 1;
|
|
|
|
|
2004-10-14 02:25:29 +02:00
|
|
|
if (!RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_KEY, &hKeyTest))
|
|
|
|
{
|
2013-10-15 21:41:10 +02:00
|
|
|
if (!RegCreateKeyA(hKeyTest, "ODBC", &hKeyS))
|
2004-10-14 02:25:29 +02:00
|
|
|
{
|
|
|
|
HKEY hKeyO;
|
2005-02-03 20:38:58 +01:00
|
|
|
|
2013-10-15 21:41:10 +02:00
|
|
|
if (!RegCreateKeyA(hKeyS, "ODBC.INI", &hKeyO))
|
2004-10-14 02:25:29 +02:00
|
|
|
{
|
|
|
|
RegCloseKey (hKeyO);
|
2005-02-03 20:38:58 +01:00
|
|
|
|
2013-10-15 21:41:10 +02:00
|
|
|
if (!RegCreateKeyA(hKeyS, "ODBCINST.INI", &hKeyO))
|
2004-10-14 02:25:29 +02:00
|
|
|
{
|
|
|
|
RegCloseKey (hKeyO);
|
|
|
|
sysfail = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey (hKeyS);
|
|
|
|
}
|
|
|
|
RegCloseKey (hKeyTest);
|
|
|
|
}
|
2005-02-03 20:38:58 +01:00
|
|
|
|
2004-10-14 02:25:29 +02:00
|
|
|
if (!sysfail)
|
|
|
|
{
|
2005-02-03 20:38:58 +01:00
|
|
|
|
|
|
|
dwRet = SHDeleteKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\ODBC");
|
2006-10-06 12:43:34 +02:00
|
|
|
ok ( ERROR_SUCCESS == dwRet, "SHDeleteKey failed, ret=(%u)\n", dwRet);
|
2005-02-03 20:38:58 +01:00
|
|
|
|
|
|
|
dwRet = RegOpenKeyA(HKEY_CURRENT_USER, REG_TEST_KEY "\\ODBC", &hKeyS);
|
|
|
|
ok ( ERROR_FILE_NOT_FOUND == dwRet, "SHDeleteKey did not delete\n");
|
|
|
|
|
2004-10-14 02:25:29 +02:00
|
|
|
if (dwRet == ERROR_SUCCESS)
|
|
|
|
RegCloseKey (hKeyS);
|
|
|
|
}
|
|
|
|
else
|
2005-02-03 20:38:58 +01:00
|
|
|
ok( 0, "Could not set up SHDeleteKey test\n");
|
2004-10-14 02:25:29 +02:00
|
|
|
}
|
2002-09-12 20:02:14 +02:00
|
|
|
|
2011-12-01 18:19:29 +01:00
|
|
|
static void test_SHRegCreateUSKeyW(void)
|
|
|
|
{
|
|
|
|
static const WCHAR subkeyW[] = {'s','u','b','k','e','y',0};
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
if (!pSHRegCreateUSKeyW)
|
|
|
|
{
|
|
|
|
win_skip("SHRegCreateUSKeyW not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pSHRegCreateUSKeyW(subkeyW, KEY_ALL_ACCESS, NULL, NULL, SHREGSET_FORCE_HKCU);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
|
|
|
|
}
|
|
|
|
|
2002-05-09 21:48:07 +02:00
|
|
|
START_TEST(shreg)
|
|
|
|
{
|
2011-12-01 18:19:29 +01:00
|
|
|
HKEY hkey = create_test_entries();
|
2005-01-21 17:18:00 +01:00
|
|
|
|
2011-12-01 18:19:29 +01:00
|
|
|
if (!hkey) return;
|
2005-01-21 17:18:00 +01:00
|
|
|
|
2011-12-01 18:19:29 +01:00
|
|
|
hshlwapi = GetModuleHandleA("shlwapi.dll");
|
2010-10-10 15:11:22 +02:00
|
|
|
|
2011-12-01 18:19:29 +01:00
|
|
|
/* SHCreateStreamOnFileEx was introduced in shlwapi v6.0 */
|
|
|
|
if(!GetProcAddress(hshlwapi, "SHCreateStreamOnFileEx")){
|
|
|
|
win_skip("Too old shlwapi version\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSHCopyKeyA = (void*)GetProcAddress(hshlwapi,"SHCopyKeyA");
|
|
|
|
pSHRegGetPathA = (void*)GetProcAddress(hshlwapi,"SHRegGetPathA");
|
|
|
|
pSHRegGetValueA = (void*)GetProcAddress(hshlwapi,"SHRegGetValueA");
|
|
|
|
pSHRegCreateUSKeyW = (void*)GetProcAddress(hshlwapi, "SHRegCreateUSKeyW");
|
|
|
|
|
|
|
|
test_SHGetValue();
|
|
|
|
test_SHRegGetValue();
|
|
|
|
test_SHQueryValueEx();
|
|
|
|
test_SHGetRegPath();
|
|
|
|
test_SHCopyKey();
|
|
|
|
test_SHDeleteKey();
|
|
|
|
test_SHRegCreateUSKeyW();
|
2010-10-10 15:11:22 +02:00
|
|
|
|
2011-12-01 18:19:29 +01:00
|
|
|
delete_key( hkey, "Software\\Wine", "Test" );
|
2002-05-09 21:48:07 +02:00
|
|
|
}
|