ReactOS 0.4.16-dev-306-g647d351
SHLoadRegUIString.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Tests for SHLoadRegUIStringA/W
5 * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include <apitest.h>
9#include <shlwapi.h>
10
13
16
18{
19 HRESULT hr;
20 CHAR szBuff[MAX_PATH];
21
22 hr = pSHLoadRegUIStringA(hKey, "TestValue1", szBuff, _countof(szBuff));
23 ok_long(hr, S_OK);
24 ok_str(szBuff, "%WINDIR%\\TEST");
25
26 hr = pSHLoadRegUIStringA(hKey, "TestValue2", szBuff, _countof(szBuff));
27 ok_long(hr, S_OK);
28 ok_str(szBuff, "Test string one.");
29}
30
32{
33 HRESULT hr;
34 WCHAR szBuff[MAX_PATH];
35
36 hr = pSHLoadRegUIStringW(hKey, L"TestValue1", szBuff, _countof(szBuff));
37 ok_long(hr, S_OK);
38 ok_wstr(szBuff, L"%WINDIR%\\TEST");
39
40 hr = pSHLoadRegUIStringW(hKey, L"TestValue2", szBuff, _countof(szBuff));
41 ok_long(hr, S_OK);
42 ok_wstr(szBuff, L"Test string one.");
43}
44
45BOOL extract_resource(const WCHAR* Filename, LPCWSTR ResourceName);
46
48{
49 LONG error;
50 HKEY hKey;
51 DWORD cbValue;
52 static const WCHAR s_szTestValue1[] = L"%WINDIR%\\TEST";
53 static const WCHAR s_szTestValue2[] = L"@SHLoadRegUIString.dll%EmptyEnvVar%,-3";
54 HMODULE hSHLWAPI;
55
56 SetEnvironmentVariableW(L"EmptyEnvVar", L"");
57
58 /* Get procedures */
59 hSHLWAPI = GetModuleHandleW(L"shlwapi");
63 {
64 skip("No procedure found\n");
65 return;
66 }
67
68 if (!extract_resource(L"SHLoadRegUIString.dll", MAKEINTRESOURCEW(101)))
69 {
70 skip("File 'SHLoadRegUIString.dll' cannot be extracted\n");
71 return;
72 }
73
74 /* Open registry key and write some test values */
77
78 cbValue = (lstrlenW(s_szTestValue1) + 1) * sizeof(WCHAR);
79 error = RegSetValueExW(hKey, L"TestValue1", 0, REG_SZ, (LPBYTE)s_szTestValue1, cbValue);
81
82 cbValue = (lstrlenW(s_szTestValue2) + 1) * sizeof(WCHAR);
83 error = RegSetValueExW(hKey, L"TestValue2", 0, REG_SZ, (LPBYTE)s_szTestValue2, cbValue);
85
86 /* The main dish */
89
90 /* Delete the test values and close the key */
91 RegDeleteValueW(hKey, L"TestValue1");
92 RegDeleteValueW(hKey, L"TestValue2");
94
95 DeleteFileW(L"SHLoadRegUIString.dll");
96}
static FN_SHLoadRegUIStringW pSHLoadRegUIStringW
BOOL extract_resource(const WCHAR *Filename, LPCWSTR ResourceName)
static FN_SHLoadRegUIStringA pSHLoadRegUIStringA
HRESULT(WINAPI * FN_SHLoadRegUIStringA)(HKEY hkey, LPCSTR value, LPSTR buf, DWORD size)
static void test_SHLoadRegUIStringW(HKEY hKey)
static void test_SHLoadRegUIStringA(HKEY hKey)
HRESULT(WINAPI * FN_SHLoadRegUIStringW)(HKEY hkey, LPCWSTR value, LPWSTR buf, DWORD size)
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok_str(x, y)
Definition: atltest.h:127
#define skip(...)
Definition: atltest.h:64
#define ok_wstr(x, y)
Definition: atltest.h:130
#define START_TEST(x)
Definition: atltest.h:75
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MAX_PATH
Definition: compat.h:34
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:259
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:940
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define S_OK
Definition: intsafe.h:52
#define REG_SZ
Definition: layer.c:22
#define error(str)
Definition: mkdosfs.c:1605
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
HRESULT hr
Definition: shlfolder.c:183
#define SHLoadRegUIString
#define _countof(array)
Definition: sndvol32.h:70
unsigned char * LPBYTE
Definition: typedefs.h:53
Definition: pdh_main.c:94
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175