ReactOS 0.4.17-dev-284-g529f3c6
SHGetFileDescription.c File Reference
#include <apitest.h>
#include <shlwapi.h>
#include <strsafe.h>
Include dependency graph for SHGetFileDescription.c:

Go to the source code of this file.

Typedefs

typedef BOOL(WINAPIFN_SHGetFileDescriptionW) (PCWSTR, PCWSTR, PCWSTR, PWSTR, PUINT)
 

Functions

static BOOL LoadFunctions (void)
 
static BOOL BuildSystemPaths (void)
 
static void TEST_QuerySizeOnly (void)
 
static void TEST_GetDescriptionNotepad (void)
 
static void TEST_GetDescriptionWinver (void)
 
static void TEST_NonExistentFile (void)
 
static void TEST_DirectoryPath (void)
 
static void TEST_TinyBuffer (void)
 
static void TEST_CustomVerKey (void)
 
static void TEST_InvalidVerKey (void)
 
 START_TEST (SHGetFileDescription)
 

Variables

static WCHAR g_notepad [MAX_PATH]
 
static WCHAR g_winver [MAX_PATH]
 
static FN_SHGetFileDescriptionW g_fnSHGetFileDescriptionW = NULL
 

Typedef Documentation

◆ FN_SHGetFileDescriptionW

typedef BOOL(WINAPI * FN_SHGetFileDescriptionW) (PCWSTR, PCWSTR, PCWSTR, PWSTR, PUINT)

Definition at line 15 of file SHGetFileDescription.c.

Function Documentation

◆ BuildSystemPaths()

static BOOL BuildSystemPaths ( void  )
static

Definition at line 32 of file SHGetFileDescription.c.

33{
34 WCHAR sys[MAX_PATH];
35 if (!GetSystemDirectoryW(sys, _countof(sys)))
36 return FALSE;
37
38 StringCchPrintfW(g_notepad, _countof(sys), L"%ls\\notepad.exe", sys);
39 StringCchPrintfW(g_winver, _countof(sys), L"%ls\\winver.exe", sys);
41}
static WCHAR g_notepad[MAX_PATH]
static WCHAR g_winver[MAX_PATH]
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2232
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2583
#define L(x)
Definition: resources.c:13
short WCHAR
Definition: pedump.c:58
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530

Referenced by START_TEST().

◆ LoadFunctions()

static BOOL LoadFunctions ( void  )
static

Definition at line 18 of file SHGetFileDescription.c.

19{
20 HMODULE hSHLWAPI = GetModuleHandleW(L"shlwapi.dll");
21 if (!hSHLWAPI)
22 hSHLWAPI = LoadLibraryW(L"shlwapi.dll");
23 if (!hSHLWAPI)
24 return FALSE;
25
28
30}
BOOL(WINAPI * FN_SHGetFileDescriptionW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, PUINT)
static FN_SHGetFileDescriptionW g_fnSHGetFileDescriptionW
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( SHGetFileDescription  )

Definition at line 137 of file SHGetFileDescription.c.

138{
139 if (!LoadFunctions())
140 {
141 skip("SHGetFileDescription not found\n");
142 return;
143 }
144
145 if (!BuildSystemPaths())
146 {
147 skip("notepad.exe and/or winver.exe not found\n");
148 return;
149 }
150
159}
static void TEST_GetDescriptionNotepad(void)
static void TEST_TinyBuffer(void)
static void TEST_InvalidVerKey(void)
static BOOL LoadFunctions(void)
static void TEST_QuerySizeOnly(void)
static void TEST_GetDescriptionWinver(void)
static void TEST_NonExistentFile(void)
static BOOL BuildSystemPaths(void)
static void TEST_CustomVerKey(void)
static void TEST_DirectoryPath(void)
#define skip(...)
Definition: atltest.h:64

◆ TEST_CustomVerKey()

static void TEST_CustomVerKey ( void  )
static

Definition at line 109 of file SHGetFileDescription.c.

110{
111 WCHAR buf[256] = L"";
112 UINT cch = _countof(buf);
114 L"\\StringFileInfo\\040904B0\\FileDescription",
115 NULL, buf, &cch);
116 ok_int(ret, TRUE);
117 ok(buf[0] != UNICODE_NULL, "buf was empty\n");
118}
#define ok(value,...)
Definition: atltest.h:57
#define ok_int(expression, result)
Definition: atltest.h:134
#define TRUE
Definition: types.h:120
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned int UINT
Definition: ndis.h:50
#define UNICODE_NULL
_In_ UINT _In_ UINT cch
Definition: shellapi.h:432

Referenced by START_TEST().

◆ TEST_DirectoryPath()

static void TEST_DirectoryPath ( void  )
static

Definition at line 85 of file SHGetFileDescription.c.

86{
87 WCHAR sys[MAX_PATH];
89
90 WCHAR buf[256] = L"";
93
94 ok_int(ret, TRUE);
95 ok(_wcsicmp(buf, L"System32") == 0, "buf was %s\n", wine_dbgstr_w(buf));
96}
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
#define wine_dbgstr_w
Definition: kernel32.h:34

Referenced by START_TEST().

◆ TEST_GetDescriptionNotepad()

static void TEST_GetDescriptionNotepad ( void  )
static

Definition at line 52 of file SHGetFileDescription.c.

53{
54 WCHAR buf[256] = L"";
57
58 ok_int(ret, TRUE);
59 ok(buf[0] != UNICODE_NULL, "buf was empty\n");
60 ok(0 < cch && cch <= _countof(buf), "cch was %u\n", cch);
61 trace("buf: %s\n", wine_dbgstr_w(buf));
62}
#define trace
Definition: atltest.h:70

Referenced by START_TEST().

◆ TEST_GetDescriptionWinver()

static void TEST_GetDescriptionWinver ( void  )
static

Definition at line 64 of file SHGetFileDescription.c.

65{
66 WCHAR buf[256] = L"";
69
70 ok_int(ret, TRUE);
71 ok(buf[0] != UNICODE_NULL, "buf was empty\n");
72 ok(0 < cch && cch <= _countof(buf), "cch was %u\n", cch);
73 trace("buf: %s\n", wine_dbgstr_w(buf));
74}

Referenced by START_TEST().

◆ TEST_InvalidVerKey()

static void TEST_InvalidVerKey ( void  )
static

Definition at line 120 of file SHGetFileDescription.c.

121{
122 WCHAR buf[256] = L"", bufNorm[256] = L"";
123 UINT cch = _countof(buf), cchNorm = _countof(bufNorm);
124
126 L"\\StringFileInfo\\FFFFFFFF\\NoSuchKey",
127 NULL, buf, &cch);
128 BOOL retNormal = g_fnSHGetFileDescriptionW(g_notepad, NULL, NULL, bufNorm, &cchNorm);
129
130 ok_int(retInvalid, TRUE);
131 ok_int(retNormal, TRUE);
132 ok(buf[0] != UNICODE_NULL, "buf was empty\n");
133 ok(lstrcmpW(buf, bufNorm) == 0, "buf was %s, bufNorm was %s\n", wine_dbgstr_w(buf),
134 wine_dbgstr_w(bufNorm));
135}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152

Referenced by START_TEST().

◆ TEST_NonExistentFile()

static void TEST_NonExistentFile ( void  )
static

Definition at line 76 of file SHGetFileDescription.c.

77{
78 WCHAR buf[256] = L"";
80 BOOL ret = g_fnSHGetFileDescriptionW(L"C:\\This\\Does\\Not\\Exist.exe", NULL, NULL,
81 buf, &cch);
83}

Referenced by START_TEST().

◆ TEST_QuerySizeOnly()

static void TEST_QuerySizeOnly ( void  )
static

Definition at line 43 of file SHGetFileDescription.c.

44{
45 UINT cch = 0;
47
48 ok_int(ret, TRUE);
49 ok(cch > 0, "cch was %u\n", cch);
50}

Referenced by START_TEST().

◆ TEST_TinyBuffer()

static void TEST_TinyBuffer ( void  )
static

Definition at line 98 of file SHGetFileDescription.c.

99{
100 WCHAR buf[1] = { L'X' };
101 UINT cch = 1;
103
104 ok_int(ret, TRUE);
106 ok_int(cch, 1);
107}

Referenced by START_TEST().

Variable Documentation

◆ g_fnSHGetFileDescriptionW

◆ g_notepad

◆ g_winver

WCHAR g_winver[MAX_PATH]
static

Definition at line 13 of file SHGetFileDescription.c.

Referenced by BuildSystemPaths(), and TEST_GetDescriptionWinver().