ReactOS 0.4.15-dev-7907-g95bf896
SHLoadRegUIString.c File Reference
#include <apitest.h>
#include <shlwapi.h>
Include dependency graph for SHLoadRegUIString.c:

Go to the source code of this file.

Typedefs

typedef HRESULT(WINAPIFN_SHLoadRegUIStringA) (HKEY hkey, LPCSTR value, LPSTR buf, DWORD size)
 
typedef HRESULT(WINAPIFN_SHLoadRegUIStringW) (HKEY hkey, LPCWSTR value, LPWSTR buf, DWORD size)
 

Functions

static void test_SHLoadRegUIStringA (HKEY hKey)
 
static void test_SHLoadRegUIStringW (HKEY hKey)
 
BOOL extract_resource (const WCHAR *Filename, LPCWSTR ResourceName)
 
 START_TEST (SHLoadRegUIString)
 

Variables

static FN_SHLoadRegUIStringA pSHLoadRegUIStringA = NULL
 
static FN_SHLoadRegUIStringW pSHLoadRegUIStringW = NULL
 

Typedef Documentation

◆ FN_SHLoadRegUIStringA

typedef HRESULT(WINAPI * FN_SHLoadRegUIStringA) (HKEY hkey, LPCSTR value, LPSTR buf, DWORD size)

Definition at line 11 of file SHLoadRegUIString.c.

◆ FN_SHLoadRegUIStringW

typedef HRESULT(WINAPI * FN_SHLoadRegUIStringW) (HKEY hkey, LPCWSTR value, LPWSTR buf, DWORD size)

Definition at line 12 of file SHLoadRegUIString.c.

Function Documentation

◆ extract_resource()

BOOL extract_resource ( const WCHAR Filename,
LPCWSTR  ResourceName 
)

Definition at line 239 of file load_notifications.c.

240{
242 DWORD dwWritten, Size;
243 HGLOBAL hGlobal;
246 HRSRC hRsrc = FindResourceW(GetModuleHandleW(NULL), ResourceName, (LPCWSTR)10);
247 ok(!!hRsrc, "Unable to find %s\n", wine_dbgstr_w(ResourceName));
248 if (!hRsrc)
249 return FALSE;
250
251 hGlobal = LoadResource(GetModuleHandleW(NULL), hRsrc);
253 pData = LockResource(hGlobal);
254
255 ok(Size && !!pData, "Unable to load %s\n", wine_dbgstr_w(ResourceName));
256 if (!Size || !pData)
257 return FALSE;
258
260
262 {
263 skip("Failed to create temp file %ls, error %lu\n", Filename, GetLastError());
264 return FALSE;
265 }
266 Success = WriteFile(Handle, pData, Size, &dwWritten, NULL);
267 ok(Success == TRUE, "WriteFile failed with %lu\n", GetLastError());
268 ok(dwWritten == Size, "WriteFile wrote %lu bytes instead of %lu\n", dwWritten, Size);
270 Success = Success && (dwWritten == Size);
271
273 return Success;
274}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
@ Success
Definition: eventcreate.c:712
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:939
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG Handle
Definition: gdb_input.c:15
#define wine_dbgstr_w
Definition: kernel32.h:34
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define UnlockResource(handle)
Definition: winbase.h:3372
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( SHLoadRegUIString  )

Definition at line 47 of file SHLoadRegUIString.c.

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 RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
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 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
FxAutoRegKey hKey
#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
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ test_SHLoadRegUIStringA()

static void test_SHLoadRegUIStringA ( HKEY  hKey)
static

Definition at line 17 of file SHLoadRegUIString.c.

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}
#define ok_str(x, y)
Definition: atltest.h:127
#define MAX_PATH
Definition: compat.h:34
#define S_OK
Definition: intsafe.h:52
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:68
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_SHLoadRegUIStringW()

static void test_SHLoadRegUIStringW ( HKEY  hKey)
static

Definition at line 31 of file SHLoadRegUIString.c.

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}
#define ok_wstr(x, y)
Definition: atltest.h:130

Referenced by START_TEST().

Variable Documentation

◆ pSHLoadRegUIStringA

FN_SHLoadRegUIStringA pSHLoadRegUIStringA = NULL
static

Definition at line 14 of file SHLoadRegUIString.c.

Referenced by START_TEST(), and test_SHLoadRegUIStringA().

◆ pSHLoadRegUIStringW

FN_SHLoadRegUIStringW pSHLoadRegUIStringW = NULL
static

Definition at line 15 of file SHLoadRegUIString.c.

Referenced by START_TEST(), and test_SHLoadRegUIStringW().