NetpGetComputerName, SHCopyKeyA and SHRegGetPathA don't exist on all

Windows platforms -> use GetModuleHandle + GetProcAddress.
This commit is contained in:
Francois Gouget 2002-09-16 22:45:22 +00:00 committed by Alexandre Julliard
parent 14fb095758
commit 3a8601948d
2 changed files with 33 additions and 10 deletions

View file

@ -27,16 +27,24 @@
#include "lmwksta.h"
#include "lmapibuf.h"
NET_API_STATUS WINAPI NetpGetComputerName(LPWSTR *Buffer);
typedef NET_API_STATUS (WINAPI *NetpGetComputerName_func)(LPWSTR *Buffer);
void run_get_comp_name_tests(void)
{
WCHAR empty[] = {0};
LPWSTR ws = empty;
ok(NetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved");
ok(ws[0] != 0, "Some value is populated to the buffer");
NetApiBufferFree(ws);
HANDLE hnetapi32 = GetModuleHandleA("netapi32.dll");
if (hnetapi32)
{
WCHAR empty[] = {0};
LPWSTR ws = empty;
NetpGetComputerName_func pNetpGetComputerName;
pNetpGetComputerName = (NetpGetComputerName_func)GetProcAddress(hnetapi32,"NetpGetComputerName");
if (pNetpGetComputerName)
{
ok((*pNetpGetComputerName)(&ws) == NERR_Success, "Computer name is retrieved");
ok(ws[0] != 0, "Some value is populated to the buffer");
NetApiBufferFree(ws);
}
}
}
void run_usergetinfo_tests(void)

View file

@ -32,6 +32,12 @@
#define REG_TEST_KEY "Software\\Wine\\Test"
#define REG_CURRENT_VERSION "Software\\Microsoft\\Windows NT\\CurrentVersion"
static HMODULE hshlwapi;
typedef DWORD (WINAPI *SHCopyKeyA_func)(HKEY,LPCSTR,HKEY,DWORD);
static SHCopyKeyA_func pSHCopyKeyA;
typedef DWORD (WINAPI *SHRegGetPathA_func)(HKEY,LPCSTR,LPCSTR,LPSTR,DWORD);
static SHRegGetPathA_func pSHRegGetPathA;
static char * sTestpath1 = "%LONGSYSTEMVAR%\\subdir1";
static char * sTestpath2 = "%FOO%\\subdir1";
@ -112,8 +118,11 @@ static void test_SHGetRegPath(void)
{
char buf[MAX_PATH];
if (!pSHRegGetPathA)
return;
strcpy(buf, sEmptyBuffer);
ok(! SHRegGetPathA(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", buf, 0), "SHRegGetPathA failed");
ok(! (*pSHRegGetPathA)(HKEY_CURRENT_USER, REG_TEST_KEY, "Test1", buf, 0), "SHRegGetPathA failed");
ok( 0 == strcmp(sExpTestpath1, buf) , "(%s)", buf);
}
@ -214,7 +223,6 @@ static void test_SHQUeryValueEx(void)
RegCloseKey(hKey);
}
static void test_SHCopyKey(void)
{
HKEY hKeySrc, hKeyDst;
@ -242,7 +250,8 @@ static void test_SHCopyKey(void)
}
ok (!SHCopyKeyA(hKeyDst, NULL, hKeySrc, 0), "failed copy");
if (pSHCopyKeyA)
ok (!(*pSHCopyKeyA)(hKeyDst, NULL, hKeySrc, 0), "failed copy");
RegCloseKey(hKeySrc);
RegCloseKey(hKeyDst);
@ -265,6 +274,12 @@ static void test_SHCopyKey(void)
START_TEST(shreg)
{
HKEY hkey = create_test_entries();
hshlwapi = GetModuleHandleA("shlwapi.dll");
if (hshlwapi)
{
pSHCopyKeyA=(SHCopyKeyA_func)GetProcAddress(hshlwapi,"SHCopyKeyA");
pSHRegGetPathA=(SHRegGetPathA_func)GetProcAddress(hshlwapi,"SHRegGetPathA");
}
test_SHGetValue();
test_SHQUeryValueEx();
test_SHGetRegPath();