ReactOS 0.4.17-dev-1190-g4c812f4
CShellLink.cpp File Reference
#include "shelltest.h"
#include <debug.h>
#include <stdio.h>
#include <shellapi.h>
#include <versionhelpers.h>
#include <shellutils.h>
Include dependency graph for CShellLink.cpp:

Go to the source code of this file.

Classes

struct  TEST_SHELL_LINK_DEF
 
struct  TEST_SHELL_ICON
 

Macros

#define NDEBUG
 
#define Test_SHGNLI(path, dir, rdir, rfile, rext, flags, ret, mustcopy)
 
#define SHGNLIFileName   L"ROS_Test_Shell32"
 

Functions

static VOID test_checklinkpath (UINT i, TEST_SHELL_LINK_DEF *testDef)
 
static VOID TestShellLink (void)
 
static VOID TestDescription (void)
 
static VOID test_iconlocation (UINT i, TEST_SHELL_ICON *testDef)
 
static VOID TestIconLocation (void)
 
 START_TEST (CShellLink)
 
 START_TEST (SHGetNewLinkInfo)
 

Variables

static TEST_SHELL_LINK_DEF linkTestList_WS03 []
 
static TEST_SHELL_LINK_DEF linkTestList_Vista []
 
static TEST_SHELL_ICON ShIconTests []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file CShellLink.cpp.

◆ SHGNLIFileName

#define SHGNLIFileName   L"ROS_Test_Shell32"

◆ Test_SHGNLI

#define Test_SHGNLI (   path,
  dir,
  rdir,
  rfile,
  rext,
  flags,
  ret,
  mustcopy 
)
Value:
do \
{ \
BOOL MustCopy, Success = SHGetNewLinkInfoW((path), (dir), lstrcpyW(Result, L"?"), &MustCopy, (flags)); \
ok(Success == (ret), "Return (%#x)\n", UINT(flags)); \
ok(MustCopy == (mustcopy), "MustCopy (%#x)\n", UINT(flags)); \
lstrcpyW(Buf, (rdir)); \
if (*Buf) PathAddBackslashW(Buf); \
lstrcatW(Buf, (rfile)); \
lstrcatW(Buf, (rext)); \
ok((!(ret) && !Success) || !_wcsicmp(Result, Buf), "%ls should be %ls (%#x)\n", Result, Buf, UINT(flags)); \
} while(0)
unsigned int dir
Definition: maze.c:112
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
GLbitfield flags
Definition: glext.h:7161
#define PathAddBackslashW
Definition: pathcch.h:302
short WCHAR
Definition: pedump.c:58
#define UINT
Definition: utils.c:29
BOOL WINAPI SHGetNewLinkInfoW(LPCWSTR pszLinkTo, LPCWSTR pszDir, LPWSTR pszName, BOOL *pfMustCopy, UINT uFlags)
Definition: shellord.c:2735
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Function Documentation

◆ START_TEST() [1/2]

START_TEST ( CShellLink  )

Definition at line 476 of file CShellLink.cpp.

477{
478 CCoInit ComInit;
479
483}

◆ START_TEST() [2/2]

START_TEST ( SHGetNewLinkInfo  )

Definition at line 485 of file CShellLink.cpp.

486{
487 CCoInit ComInit;
488 LPCWSTR DotUrlOn7 = IsReactOS() || GetNTVersion() >= _WIN32_WINNT_WIN7 ? L".url" : L".lnk";
489 WCHAR FullTarget[MAX_PATH], Dir[MAX_PATH];
490
492
493 GetModuleFileNameW(GetModuleHandleW(L"KERNEL32"), FullTarget, _countof(FullTarget));
494 LPWSTR TargetFile = PathFindFileNameW(FullTarget);
495
496 #define Test_SHGNLI(path, dir, rdir, rfile, rext, flags, ret, mustcopy) do \
497 { \
498 WCHAR Result[MAX_PATH], Buf[MAX_PATH]; \
499 BOOL MustCopy, Success = SHGetNewLinkInfoW((path), (dir), lstrcpyW(Result, L"?"), &MustCopy, (flags)); \
500 ok(Success == (ret), "Return (%#x)\n", UINT(flags)); \
501 ok(MustCopy == (mustcopy), "MustCopy (%#x)\n", UINT(flags)); \
502 lstrcpyW(Buf, (rdir)); \
503 if (*Buf) PathAddBackslashW(Buf); \
504 lstrcatW(Buf, (rfile)); \
505 lstrcatW(Buf, (rext)); \
506 ok((!(ret) && !Success) || !_wcsicmp(Result, Buf), "%ls should be %ls (%#x)\n", Result, Buf, UINT(flags)); \
507 } while(0)
508
509 Test_SHGNLI(FullTarget, Dir, Dir, TargetFile, L".lnk", 0, 1, 0);
510
511 CComHeapPtr<ITEMIDLIST> pidl(SHELL_SimpleIDListFromPath(FullTarget));
512 Test_SHGNLI((LPWSTR)(LPITEMIDLIST)pidl, Dir, Dir, TargetFile, L".lnk", SHGNLI_PIDL, 1, 0);
513
514 Test_SHGNLI(FullTarget, Dir, L"", TargetFile, L".lnk", SHGNLI_NOUNIQUE, 1, 0);
515
516 Test_SHGNLI(FullTarget, Dir, Dir, TargetFile, L"", SHGNLI_NOLNK, 1, 0);
517 Test_SHGNLI(FullTarget, Dir, L"", TargetFile, L"", SHGNLI_NOLNK | SHGNLI_NOUNIQUE, 1, 0);
518 Test_SHGNLI(FullTarget, Dir, Dir, TargetFile, L"", SHGNLI_NOLNK | SHGNLI_USEURLEXT, 1, 0);
519
520 Test_SHGNLI(FullTarget, Dir, Dir, TargetFile, DotUrlOn7, SHGNLI_USEURLEXT, 1, 0);
521
522 PathRemoveExtensionW(FullTarget);
523 Test_SHGNLI(FullTarget, Dir, L"", L"", L"", 0, 0, 0); // Target does not exist
524
525 #define SHGNLIFileName L"ROS_Test_Shell32"
526 PathAppendW(lstrcpyW(FullTarget, Dir), SHGNLIFileName L".lnk");
527 CloseHandle(CreateFileW(FullTarget, 0, 7, NULL, OPEN_ALWAYS, 0, NULL));
528 Test_SHGNLI(FullTarget, Dir, Dir, SHGNLIFileName L" (2)", L".lnk", 0, 1, 1);
529 Test_SHGNLI(FullTarget, Dir, L"", SHGNLIFileName, L".lnk", SHGNLI_NOUNIQUE, 1, 1);
530 Test_SHGNLI(FullTarget, Dir, Dir, SHGNLIFileName L" (2)", L".lnk", SHGNLI_NOLNK, 1, 1); // SFGAO_LINK ignores SHGNLI_NOLNK
531 DeleteFileW(FullTarget);
532}
#define GetNTVersion()
Definition: apitest.h:17
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:739
#define CreateFileW
Definition: compat.h:741
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
void WINAPI PathRemoveExtensionW(WCHAR *path)
Definition: path.c:1922
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1677
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:4394
#define OPEN_ALWAYS
Definition: disk.h:70
#define PathAppendW
Definition: pathcch.h:310
#define _WIN32_WINNT_WIN7
Definition: sdkddkver.h:28
#define SHGNLI_NOUNIQUE
Definition: shellapi.h:602
#define SHGNLI_NOLNK
Definition: shellapi.h:603
#define SHGNLI_USEURLEXT
Definition: shellapi.h:605
#define SHGNLI_PIDL
Definition: shellapi.h:600
static LPITEMIDLIST SHELL_SimpleIDListFromPath(LPCWSTR pszPath)
Definition: shelltest.h:22
#define CSIDL_PROFILE
Definition: shlobj.h:2259
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define _countof(array)
Definition: sndvol32.h:70
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56

◆ test_checklinkpath()

static VOID test_checklinkpath ( UINT  i,
TEST_SHELL_LINK_DEF *  testDef 
)
static

Definition at line 156 of file CShellLink.cpp.

157{
158static WCHAR evVar[MAX_PATH];
159
160 HRESULT hr, expectedHr;
161 WCHAR wPathOut[MAX_PATH];
162 BOOL expandPathOut;
163 PCWSTR expectedPathOut;
164 CComPtr<IShellLinkW> psl;
165 UINT i1;
166 DWORD flags;
167
168 hr = CoCreateInstance(CLSID_ShellLink,
169 NULL,
170 CLSCTX_INPROC_SERVER,
171 IID_PPV_ARG(IShellLinkW, &psl));
172 ok(hr == S_OK, "CoCreateInstance, hr = 0x%lx\n", hr);
173 if (FAILED(hr))
174 {
175 skip("Could not instantiate CShellLink\n");
176 return;
177 }
178
179 hr = psl->SetPath(testDef->pathIn);
180 ok(hr == testDef->hrSetPath, "IShellLink::SetPath(%d), got hr = 0x%lx, expected 0x%lx\n", i, hr, testDef->hrSetPath);
181
182 expectedPathOut = NULL;
183 for (i1 = 0; i1 <= 1; i1++)
184 {
185 if (i1 == 0) /* Usually SLGP_SHORTPATH */
186 {
187 flags = testDef->flags1;
188 expandPathOut = testDef->expandPathOut1;
189 expectedPathOut = testDef->pathOut1;
190 expectedHr = testDef->hrGetPath1;
191 }
192 else // if (i1 == 1) /* Usually SLGP_RAWPATH */
193 {
194 flags = testDef->flags2;
195 expandPathOut = testDef->expandPathOut2;
196 expectedPathOut = testDef->pathOut2;
197 expectedHr = testDef->hrGetPath2;
198 }
199
200 /* Patch some variables */
201 if (expandPathOut)
202 {
203 ExpandEnvironmentStringsW(expectedPathOut, evVar, _countof(evVar));
204 DPRINT("** %S **\n",evVar);
205 expectedPathOut = evVar;
206 }
207
208 hr = psl->GetPath(wPathOut, _countof(wPathOut), NULL, flags);
209 ok(hr == expectedHr,
210 "IShellLink::GetPath(%d), flags 0x%lx, got hr = 0x%lx, expected 0x%lx\n",
211 i, flags, hr, expectedHr);
212 ok(_wcsicmp(wPathOut, expectedPathOut) == 0,
213 "IShellLink::GetPath(%d), flags 0x%lx, in %S, got %S, expected %S\n",
214 i, flags, testDef->pathIn, wPathOut, expectedPathOut);
215 }
216}
#define IID_PPV_ARG(Itype, ppType)
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
HRESULT hr
Definition: delayimp.cpp:582
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:492
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: sysinfo.c:13
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define DPRINT
Definition: sndvol32.h:73
const uint16_t * PCWSTR
Definition: typedefs.h:57

Referenced by TestShellLink().

◆ test_iconlocation()

static VOID test_iconlocation ( UINT  i,
TEST_SHELL_ICON *  testDef 
)
static

Definition at line 333 of file CShellLink.cpp.

334{
335 HRESULT hr;
336 CComPtr<IShellLinkW> psl;
337 CComPtr<IExtractIconW> pei;
338 INT iIcon;
339 UINT wFlags;
340 PCWSTR pszExplorer = L"%SystemRoot%\\explorer.exe";
342 WCHAR szPath2[MAX_PATH];
343
344 hr = CoCreateInstance(CLSID_ShellLink,
345 NULL,
346 CLSCTX_INPROC_SERVER,
347 IID_PPV_ARG(IShellLinkW, &psl));
348 ok(hr == S_OK, "CoCreateInstance, hr = 0x%lx\n", hr);
349 if (FAILED(hr))
350 {
351 skip("Could not instantiate CShellLink\n");
352 return;
353 }
354
355 /* Set the path to a file */
357 hr = psl->SetPath(szPath);
358 ok(hr == S_OK, "IShellLink::SetPath failed, hr = 0x%lx\n", hr);
359
360 /*
361 * This test shows that this does not imply that the icon is automatically
362 * set and be retrieved naively by a call to IShellLink::GetIconLocation.
363 */
364 iIcon = 0xdeadbeef;
365 wcscpy(szPath, L"garbage");
366 hr = psl->GetIconLocation(szPath, _countof(szPath), &iIcon);
367 ok(hr == S_OK, "IShellLink::GetIconLocation(%d) failed, hr = 0x%lx\n", i, hr);
368 ok(*szPath == L'\0', "IShellLink::GetIconLocation(%d) returned '%S'\n", i, szPath);
369 ok(iIcon == 0, "IShellLink::GetIconLocation(%d) returned %d, expected %d\n", i, iIcon, 0);
370
371 /* Try to grab the IExtractIconW interface */
373 ok(hr == S_OK, "IShellLink::QueryInterface(IExtractIconW)(%d) failed, hr = 0x%lx\n", i, hr);
374 if (!pei)
375 {
376 win_skip("No IExtractIconW interface\n");
377 return;
378 }
379
380 iIcon = wFlags = 0xdeadbeef;
381 wcscpy(szPath, L"garbage");
382 hr = pei->GetIconLocation(GIL_DEFAULTICON, szPath, _countof(szPath), &iIcon, &wFlags);
383 ok(hr == testDef->hrDefIcon, "IExtractIcon::GetIconLocation(%d) returned hr = 0x%lx, expected 0x%lx\n", i, hr, testDef->hrDefIcon);
384 ok(*szPath == L'\0', "IExtractIcon::GetIconLocation(%d) returned '%S'\n", i, szPath);
385 // ok(iIcon == 0, "IExtractIcon::GetIconLocation(%d) returned %d\n", i, iIcon);
386
387 iIcon = wFlags = 0xdeadbeef;
388 wcscpy(szPath, L"garbage");
389 hr = pei->GetIconLocation(GIL_FORSHORTCUT, szPath, _countof(szPath), &iIcon, &wFlags);
390 ok(hr == testDef->hrForShrt, "IExtractIcon::GetIconLocation(%d) returned hr = 0x%lx, expected 0x%lx\n", i, hr, testDef->hrForShrt);
391 // Here, both szPath and iIcon are untouched...
392
393 iIcon = wFlags = 0xdeadbeef;
394 wcscpy(szPath, L"garbage");
395 hr = pei->GetIconLocation(GIL_FORSHELL, szPath, _countof(szPath), &iIcon, &wFlags);
396 ok(hr == testDef->hrForShell, "IExtractIcon::GetIconLocation(%d) returned hr = 0x%lx, expected 0x%lx\n", i, hr, testDef->hrForShell);
397 ok(wFlags == testDef->Flags, "IExtractIcon::GetIconLocation(%d) returned wFlags = 0x%x, expected 0x%x\n", i, wFlags, testDef->Flags);
398 /*
399 * Actually, even if wFlags specifies GIL_NOTFILENAME, a correct file name is returned
400 * for executables only (at least...), otherwise we can get an asterix '*'.
401 */
402 ExpandEnvironmentStringsW(testDef->IconPath, szPath2, _countof(szPath2));
403 ok(_wcsicmp(szPath2, szPath) == 0, "IExtractIcon::GetIconLocation(%d) returned '%S', expected '%S'\n", i, szPath, szPath2);
404
405 // ok(*szPath == L'\0', "IExtractIcon::GetIconLocation returned '%S'\n", szPath);
406 // ok(iIcon == 0, "IExtractIcon::GetIconLocation returned %d\n", iIcon);
407 // ok(FALSE, "hr = 0x%lx, szPath = '%S', iIcon = %d, wFlags = %d\n", hr, szPath, iIcon, wFlags);
408
409
410 /*
411 * Now we test what happens when we explicitly set an icon to the shortcut.
412 * Note that actually, SetIconLocation() does not verify whether the file
413 * really exists.
414 */
415 hr = psl->SetIconLocation(pszExplorer, 1);
416 ok(hr == S_OK, "IShellLink::SetIconLocation(%d) failed, hr = 0x%lx\n", i, hr);
417
418 /*
419 * First, we call IShellLink::GetIconLocation. We retrieve
420 * exactly what we specified with SetIconLocation.
421 */
422 iIcon = 0xdeadbeef;
423 wcscpy(szPath, L"garbage");
424 hr = psl->GetIconLocation(szPath, _countof(szPath), &iIcon);
425 ok(hr == S_OK, "IShellLink::GetIconLocation(%d) failed, hr = 0x%lx\n", i, hr);
426 ok(wcscmp(szPath, pszExplorer) == 0, "IShellLink::GetIconLocation(%d) returned '%S', expected '%S'\n", i, szPath, pszExplorer);
427 ok(iIcon == 1, "IShellLink::GetIconLocation(%d) returned %d, expected %d\n", i, iIcon, 1);
428
429 /*
430 * Now we test what happens with IExtractIcon::GetIconLocation.
431 * We see that it retrieves the icon of the shortcut's underlying file.
432 */
433 iIcon = wFlags = 0xdeadbeef;
434 wcscpy(szPath, L"garbage");
435 hr = pei->GetIconLocation(GIL_DEFAULTICON, szPath, _countof(szPath), &iIcon, &wFlags);
436 ok(hr == testDef->hrDefIcon, "IExtractIcon::GetIconLocation(%d) returned hr = 0x%lx, expected 0x%lx\n", i, hr, testDef->hrDefIcon);
437 ok(*szPath == L'\0', "IExtractIcon::GetIconLocation(%d) returned '%S'\n", i, szPath);
438 // ok(iIcon == 0, "IExtractIcon::GetIconLocation(%d) returned %d\n", i, iIcon);
439
440 iIcon = wFlags = 0xdeadbeef;
441 wcscpy(szPath, L"garbage");
442 hr = pei->GetIconLocation(GIL_FORSHORTCUT, szPath, _countof(szPath), &iIcon, &wFlags);
443 ok(hr == testDef->hrForShrt, "IExtractIcon::GetIconLocation(%d) returned hr = 0x%lx, expected 0x%lx\n", i, hr, testDef->hrForShrt);
444 // Here, both szPath and iIcon are untouched...
445
446 iIcon = wFlags = 0xdeadbeef;
447 wcscpy(szPath, L"garbage");
448 hr = pei->GetIconLocation(GIL_FORSHELL, szPath, _countof(szPath), &iIcon, &wFlags);
449 ok(hr == testDef->hrForShell, "IExtractIcon::GetIconLocation(%d) returned hr = 0x%lx, expected 0x%lx\n", i, hr, testDef->hrForShell);
450 ok(wFlags == testDef->Flags, "IExtractIcon::GetIconLocation(%d) returned wFlags = 0x%x, expected 0x%x\n", i, wFlags, testDef->Flags);
451 /*
452 * Actually, even if wFlags specifies GIL_NOTFILENAME, a correct file name is returned
453 * for executables only (at least...), otherwise we can get an asterix '*'.
454 */
455 ExpandEnvironmentStringsW(testDef->IconPath, szPath2, _countof(szPath2));
456 ok(_wcsicmp(szPath2, szPath) == 0, "IExtractIcon::GetIconLocation(%d) returned '%S', expected '%S'\n", i, szPath, szPath2);
457
458 // ok(*szPath == L'\0', "IExtractIcon::GetIconLocation returned '%S'\n", szPath);
459 // ok(iIcon == 0, "IExtractIcon::GetIconLocation returned %d\n", iIcon);
460 // ok(FALSE, "hr = 0x%lx, szPath = '%S', iIcon = %d, wFlags = %d\n", hr, szPath, iIcon, wFlags);
461}
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define win_skip
Definition: minitest.h:67
LPCWSTR szPath
Definition: env.c:37
wcscpy
HRESULT hrForShell
Definition: CShellLink.cpp:305
int32_t INT
Definition: typedefs.h:58
WINBASEAPI _In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon_undoc.h:337

Referenced by TestIconLocation().

◆ TestDescription()

static VOID TestDescription ( void  )
static

Definition at line 250 of file CShellLink.cpp.

251{
252 HRESULT hr;
253 CComPtr<IShellLinkW> psl;
254 WCHAR buffer[64];
255 PCWSTR testDescription = L"This is a test description";
256
257 /* Test SetDescription */
258 hr = CoCreateInstance(CLSID_ShellLink,
259 NULL,
260 CLSCTX_INPROC_SERVER,
261 IID_PPV_ARG(IShellLinkW, &psl));
262 ok(hr == S_OK, "CoCreateInstance, hr = 0x%lx\n", hr);
263 if (FAILED(hr))
264 {
265 skip("Could not instantiate CShellLink\n");
266 return;
267 }
268
269 memset(buffer, 0x55, sizeof(buffer));
270 hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
271 ok(hr == S_OK, "IShellLink::GetDescription returned hr = 0x%lx\n", hr);
272 ok(buffer[0] == 0, "buffer[0] = %x\n", buffer[0]);
273 ok(buffer[1] == 0x5555, "buffer[1] = %x\n", buffer[1]);
274
275 hr = psl->SetDescription(testDescription);
276 ok(hr == S_OK, "IShellLink::SetDescription returned hr = 0x%lx\n", hr);
277
278 memset(buffer, 0x55, sizeof(buffer));
279 hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
280 ok(hr == S_OK, "IShellLink::GetDescription returned hr = 0x%lx\n", hr);
281 ok(buffer[wcslen(testDescription)] == 0, "buffer[n] = %x\n", buffer[wcslen(testDescription)]);
282 ok(buffer[wcslen(testDescription) + 1] == 0x5555, "buffer[n+1] = %x\n", buffer[wcslen(testDescription) + 1]);
283 ok(!wcscmp(buffer, testDescription), "buffer = '%ls'\n", buffer);
284
285 hr = psl->SetDescription(NULL);
286 ok(hr == S_OK, "IShellLink::SetDescription returned hr = 0x%lx\n", hr);
287
288 memset(buffer, 0x55, sizeof(buffer));
289 hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
290 ok(hr == S_OK, "IShellLink::GetDescription returned hr = 0x%lx\n", hr);
291 ok(buffer[0] == 0, "buffer[0] = %x\n", buffer[0]);
292 ok(buffer[1] == 0x5555, "buffer[1] = %x\n", buffer[1]);
293}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
GLuint buffer
Definition: glext.h:5915
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ TestIconLocation()

static VOID TestIconLocation ( void  )
static

Definition at line 465 of file CShellLink.cpp.

466{
467 UINT i;
468
469 for (i = 0; i < _countof(ShIconTests); ++i)
470 {
472 }
473}

Referenced by START_TEST().

◆ TestShellLink()

static VOID TestShellLink ( void  )
static

Definition at line 220 of file CShellLink.cpp.

221{
222 UINT i, TestListCnt;
224
225 /* Needed for test */
226 SetEnvironmentVariableW(L"shell", L"cmd.exe");
227
229 {
231 TestListCnt = _countof(linkTestList_WS03);
232 }
233 else
234 {
236 TestListCnt = _countof(linkTestList_Vista);
237 }
238
239 for (i = 0; i < TestListCnt; ++i)
240 {
241 DPRINT("IShellLink-Test(%d): %S\n", i, Test[i].pathIn);
243 }
244
246}
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:232
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23

Referenced by START_TEST().

Variable Documentation

◆ linkTestList_Vista

TEST_SHELL_LINK_DEF linkTestList_Vista[]
static

Definition at line 95 of file CShellLink.cpp.

Referenced by TestShellLink().

◆ linkTestList_WS03

TEST_SHELL_LINK_DEF linkTestList_WS03[]
static

Definition at line 36 of file CShellLink.cpp.

Referenced by TestShellLink().

◆ ShIconTests

TEST_SHELL_ICON ShIconTests[]
static
Initial value:
=
{
{L"%SystemRoot%\\system32\\cmd.exe", S_FALSE, E_INVALIDARG,
S_OK, L"%SystemRoot%\\system32\\cmd.exe", GIL_NOTFILENAME | GIL_PERINSTANCE},
{L"%SystemRoot%\\system32\\autochk.exe", S_FALSE, E_INVALIDARG,
S_OK, L"%SystemRoot%\\system32\\autochk.exe", GIL_NOTFILENAME | GIL_PERINSTANCE},
{L"%SystemRoot%\\system32\\shell32.dll", S_FALSE, E_INVALIDARG,
S_OK, L"*", GIL_NOTFILENAME | GIL_PERCLASS},
{L"%SystemRoot%\\non-existent-file.sdf", S_FALSE, E_INVALIDARG,
S_OK, L"*", GIL_NOTFILENAME | GIL_PERCLASS},
{L"c:\\non-existent-path\\non-existent-file.sdf", S_FALSE, E_INVALIDARG,
S_OK, L"*", GIL_NOTFILENAME | GIL_PERCLASS},
}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define S_FALSE
Definition: winerror.h:3451

Definition at line 310 of file CShellLink.cpp.

Referenced by TestIconLocation().