2 * Unit tests for shelllinks
4 * Copyright 2004 Mike McCormack
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 * This is a test program for the SHGet{Special}Folder{Path|Location} functions
20 * of shell32, that get either a filesytem path or a LPITEMIDLIST (shell
21 * namespace) path for a given folder (CSIDL value).
31 #include "wine/test.h"
33 #include "shell32_test.h"
36 typedef void (WINAPI *fnILFree)(LPITEMIDLIST);
37 typedef BOOL (WINAPI *fnILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
38 typedef HRESULT (WINAPI *fnSHILCreateFromPath)(LPCWSTR, LPITEMIDLIST *,DWORD*);
40 static fnILFree pILFree;
41 static fnILIsEqual pILIsEqual;
42 static fnSHILCreateFromPath pSHILCreateFromPath;
44 static const GUID _IID_IShellLinkDataList = {
45 0x45e2b4ae, 0xb1c3, 0x11d0,
46 { 0xb9, 0x2f, 0x00, 0xa0, 0xc9, 0x03, 0x12, 0xe1 }
49 static const WCHAR lnkfile[]= { 'C',':','\\','t','e','s','t','.','l','n','k',0 };
50 static const WCHAR notafile[]= { 'C',':','\\','n','o','n','e','x','i','s','t','e','n','t','\\','f','i','l','e',0 };
53 /* For some reason SHILCreateFromPath does not work on Win98 and
54 * SHSimpleIDListFromPathA does not work on NT4. But if we call both we
55 * get what we want on all platforms.
57 static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathAW)(LPCVOID);
59 static LPITEMIDLIST path_to_pidl(const char* path)
63 if (!pSHSimpleIDListFromPathAW)
65 HMODULE hdll=LoadLibraryA("shell32.dll");
66 pSHSimpleIDListFromPathAW=(void*)GetProcAddress(hdll, (char*)162);
67 if (!pSHSimpleIDListFromPathAW)
68 trace("SHSimpleIDListFromPathAW not found in shell32.dll\n");
72 /* pSHSimpleIDListFromPathAW maps to A on non NT platforms */
73 if (pSHSimpleIDListFromPathAW && (GetVersion() & 0x80000000))
74 pidl=pSHSimpleIDListFromPathAW(path);
82 len=MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
83 pathW=HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
84 MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, len);
86 r=pSHILCreateFromPath(pathW, &pidl, NULL);
88 ok(SUCCEEDED(r), "SHILCreateFromPath failed (0x%08x)\n", r);
90 HeapFree(GetProcessHeap(), 0, pathW);
97 * Test manipulation of an IShellLink's properties.
100 static void test_get_set(void)
104 char mypath[MAX_PATH];
105 char buffer[INFOTIPSIZE];
106 LPITEMIDLIST pidl, tmp_pidl;
111 r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
112 &IID_IShellLinkA, (LPVOID*)&sl);
113 ok(SUCCEEDED(r), "no IID_IShellLinkA (0x%08x)\n", r);
117 /* Test Getting / Setting the description */
118 strcpy(buffer,"garbage");
119 r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
120 ok(SUCCEEDED(r), "GetDescription failed (0x%08x)\n", r);
121 ok(*buffer=='\0', "GetDescription returned '%s'\n", buffer);
123 str="Some description";
124 r = IShellLinkA_SetDescription(sl, str);
125 ok(SUCCEEDED(r), "SetDescription failed (0x%08x)\n", r);
127 strcpy(buffer,"garbage");
128 r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
129 ok(SUCCEEDED(r), "GetDescription failed (0x%08x)\n", r);
130 ok(lstrcmp(buffer,str)==0, "GetDescription returned '%s'\n", buffer);
132 /* Test Getting / Setting the work directory */
133 strcpy(buffer,"garbage");
134 r = IShellLinkA_GetWorkingDirectory(sl, buffer, sizeof(buffer));
135 ok(SUCCEEDED(r), "GetWorkingDirectory failed (0x%08x)\n", r);
136 ok(*buffer=='\0', "GetWorkingDirectory returned '%s'\n", buffer);
138 str="c:\\nonexistent\\directory";
139 r = IShellLinkA_SetWorkingDirectory(sl, str);
140 ok(SUCCEEDED(r), "SetWorkingDirectory failed (0x%08x)\n", r);
142 strcpy(buffer,"garbage");
143 r = IShellLinkA_GetWorkingDirectory(sl, buffer, sizeof(buffer));
144 ok(SUCCEEDED(r), "GetWorkingDirectory failed (0x%08x)\n", r);
145 ok(lstrcmpi(buffer,str)==0, "GetWorkingDirectory returned '%s'\n", buffer);
147 /* Test Getting / Setting the work directory */
148 strcpy(buffer,"garbage");
149 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
150 ok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
151 ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
153 r = IShellLinkA_SetPath(sl, "");
154 ok(r==S_OK, "SetPath failed (0x%08x)\n", r);
156 strcpy(buffer,"garbage");
157 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
158 ok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
159 ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
161 str="c:\\nonexistent\\file";
162 r = IShellLinkA_SetPath(sl, str);
163 ok(r==S_FALSE, "SetPath failed (0x%08x)\n", r);
165 strcpy(buffer,"garbage");
166 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
167 ok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
168 ok(lstrcmpi(buffer,str)==0, "GetPath returned '%s'\n", buffer);
170 /* Get some a real path to play with */
171 r=GetModuleFileName(NULL, mypath, sizeof(mypath));
172 ok(r>=0 && r<sizeof(mypath), "GetModuleFileName failed (%d)\n", r);
174 /* Test the interaction of SetPath and SetIDList */
176 r = IShellLinkA_GetIDList(sl, &tmp_pidl);
177 ok(SUCCEEDED(r), "GetIDList failed (0x%08x)\n", r);
180 strcpy(buffer,"garbage");
181 r=SHGetPathFromIDListA(tmp_pidl, buffer);
183 ok(r, "SHGetPathFromIDListA failed\n");
186 ok(lstrcmpi(buffer,str)==0, "GetIDList returned '%s'\n", buffer);
189 pidl=path_to_pidl(mypath);
191 ok(pidl!=NULL, "path_to_pidl returned a NULL pidl\n");
196 r = IShellLinkA_SetIDList(sl, pidl);
197 ok(SUCCEEDED(r), "SetIDList failed (0x%08x)\n", r);
200 r = IShellLinkA_GetIDList(sl, &tmp_pidl);
201 ok(SUCCEEDED(r), "GetIDList failed (0x%08x)\n", r);
202 ok(tmp_pidl && pILIsEqual(pidl, tmp_pidl),
203 "GetIDList returned an incorrect pidl\n");
205 /* tmp_pidl is owned by IShellLink so we don't free it */
208 strcpy(buffer,"garbage");
209 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
210 ok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
211 ok(lstrcmpi(buffer, mypath)==0, "GetPath returned '%s'\n", buffer);
214 /* test path with quotes */
215 r = IShellLinkA_SetPath(sl, "\"c:\\nonexistent\\file\"");
216 ok(r==S_FALSE, "SetPath failed (0x%08x)\n", r);
218 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
219 ok(r==S_OK, "GetPath failed (0x%08x)\n", r);
220 ok(!lstrcmp(buffer, "C:\\nonexistent\\file"), "case doesn't match\n");
222 r = IShellLinkA_SetPath(sl, "\"c:\\foo");
223 ok(r==S_FALSE, "SetPath failed (0x%08x)\n", r);
225 r = IShellLinkA_SetPath(sl, "\"\"c:\\foo");
226 ok(r==S_FALSE, "SetPath failed (0x%08x)\n", r);
228 r = IShellLinkA_SetPath(sl, "c:\\foo\"");
229 ok(r==S_FALSE, "SetPath failed (0x%08x)\n", r);
231 r = IShellLinkA_SetPath(sl, "\"\"c:\\foo\"");
232 ok(r==S_FALSE, "SetPath failed (0x%08x)\n", r);
234 r = IShellLinkA_SetPath(sl, "\"\"c:\\foo\"\"");
235 ok(r==S_FALSE, "SetPath failed (0x%08x)\n", r);
237 /* Test Getting / Setting the arguments */
238 strcpy(buffer,"garbage");
239 r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
240 ok(SUCCEEDED(r), "GetArguments failed (0x%08x)\n", r);
241 ok(*buffer=='\0', "GetArguments returned '%s'\n", buffer);
243 str="param1 \"spaced param2\"";
244 r = IShellLinkA_SetArguments(sl, str);
245 ok(SUCCEEDED(r), "SetArguments failed (0x%08x)\n", r);
247 strcpy(buffer,"garbage");
248 r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
249 ok(SUCCEEDED(r), "GetArguments failed (0x%08x)\n", r);
250 ok(lstrcmp(buffer,str)==0, "GetArguments returned '%s'\n", buffer);
252 /* Test Getting / Setting showcmd */
254 r = IShellLinkA_GetShowCmd(sl, &i);
255 ok(SUCCEEDED(r), "GetShowCmd failed (0x%08x)\n", r);
256 ok(i==SW_SHOWNORMAL, "GetShowCmd returned %d\n", i);
258 r = IShellLinkA_SetShowCmd(sl, SW_SHOWMAXIMIZED);
259 ok(SUCCEEDED(r), "SetShowCmd failed (0x%08x)\n", r);
262 r = IShellLinkA_GetShowCmd(sl, &i);
263 ok(SUCCEEDED(r), "GetShowCmd failed (0x%08x)\n", r);
264 ok(i==SW_SHOWMAXIMIZED, "GetShowCmd returned %d'\n", i);
266 /* Test Getting / Setting the icon */
268 strcpy(buffer,"garbage");
269 r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
271 ok(SUCCEEDED(r), "GetIconLocation failed (0x%08x)\n", r);
273 ok(*buffer=='\0', "GetIconLocation returned '%s'\n", buffer);
274 ok(i==0, "GetIconLocation returned %d\n", i);
276 str="c:\\nonexistent\\file";
277 r = IShellLinkA_SetIconLocation(sl, str, 0xbabecafe);
278 ok(SUCCEEDED(r), "SetIconLocation failed (0x%08x)\n", r);
281 r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
282 ok(SUCCEEDED(r), "GetIconLocation failed (0x%08x)\n", r);
283 ok(lstrcmpi(buffer,str)==0, "GetArguments returned '%s'\n", buffer);
284 ok(i==0xbabecafe, "GetIconLocation returned %d'\n", i);
286 /* Test Getting / Setting the hot key */
288 r = IShellLinkA_GetHotkey(sl, &w);
289 ok(SUCCEEDED(r), "GetHotkey failed (0x%08x)\n", r);
290 ok(w==0, "GetHotkey returned %d\n", w);
292 r = IShellLinkA_SetHotkey(sl, 0x5678);
293 ok(SUCCEEDED(r), "SetHotkey failed (0x%08x)\n", r);
296 r = IShellLinkA_GetHotkey(sl, &w);
297 ok(SUCCEEDED(r), "GetHotkey failed (0x%08x)\n", r);
298 ok(w==0x5678, "GetHotkey returned %d'\n", w);
300 IShellLinkA_Release(sl);
305 * Test saving and loading .lnk files
308 #define lok ok_(__FILE__, line)
309 #define lok_todo_4(todo_flag,a,b,c,d) \
310 if ((todo & todo_flag) == 0) lok((a), (b), (c), (d)); \
311 else todo_wine lok((a), (b), (c), (d));
312 #define lok_todo_2(todo_flag,a,b) \
313 if ((todo & todo_flag) == 0) lok((a), (b)); \
314 else todo_wine lok((a), (b));
315 #define check_lnk(a,b,c) check_lnk_(__LINE__, (a), (b), (c))
317 void create_lnk_(int line, const WCHAR* path, lnk_desc_t* desc, int save_fails)
323 r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
324 &IID_IShellLinkA, (LPVOID*)&sl);
325 lok(SUCCEEDED(r), "no IID_IShellLinkA (0x%08x)\n", r);
329 if (desc->description)
331 r = IShellLinkA_SetDescription(sl, desc->description);
332 lok(SUCCEEDED(r), "SetDescription failed (0x%08x)\n", r);
336 r = IShellLinkA_SetWorkingDirectory(sl, desc->workdir);
337 lok(SUCCEEDED(r), "SetWorkingDirectory failed (0x%08x)\n", r);
341 r = IShellLinkA_SetPath(sl, desc->path);
342 lok(SUCCEEDED(r), "SetPath failed (0x%08x)\n", r);
346 r = IShellLinkA_SetIDList(sl, desc->pidl);
347 lok(SUCCEEDED(r), "SetIDList failed (0x%08x)\n", r);
351 r = IShellLinkA_SetArguments(sl, desc->arguments);
352 lok(SUCCEEDED(r), "SetArguments failed (0x%08x)\n", r);
356 r = IShellLinkA_SetShowCmd(sl, desc->showcmd);
357 lok(SUCCEEDED(r), "SetShowCmd failed (0x%08x)\n", r);
361 r = IShellLinkA_SetIconLocation(sl, desc->icon, desc->icon_id);
362 lok(SUCCEEDED(r), "SetIconLocation failed (0x%08x)\n", r);
366 r = IShellLinkA_SetHotkey(sl, desc->hotkey);
367 lok(SUCCEEDED(r), "SetHotkey failed (0x%08x)\n", r);
370 r = IShellLinkW_QueryInterface(sl, &IID_IPersistFile, (LPVOID*)&pf);
371 lok(SUCCEEDED(r), "no IID_IPersistFile (0x%08x)\n", r);
374 r = IPersistFile_Save(pf, path, TRUE);
378 lok(SUCCEEDED(r), "save failed (0x%08x)\n", r);
383 lok(SUCCEEDED(r), "save failed (0x%08x)\n", r);
385 IPersistFile_Release(pf);
388 IShellLinkA_Release(sl);
391 static void check_lnk_(int line, const WCHAR* path, lnk_desc_t* desc, int todo)
396 char buffer[INFOTIPSIZE];
398 r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
399 &IID_IShellLinkA, (LPVOID*)&sl);
400 lok(SUCCEEDED(r), "no IID_IShellLinkA (0x%08x)\n", r);
404 r = IShellLinkA_QueryInterface(sl, &IID_IPersistFile, (LPVOID*)&pf);
405 lok(SUCCEEDED(r), "no IID_IPersistFile (0x%08x)\n", r);
408 IShellLinkA_Release(sl);
412 r = IPersistFile_Load(pf, path, STGM_READ);
413 lok(SUCCEEDED(r), "load failed (0x%08x)\n", r);
414 IPersistFile_Release(pf);
417 IShellLinkA_Release(sl);
421 if (desc->description)
423 strcpy(buffer,"garbage");
424 r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
425 lok(SUCCEEDED(r), "GetDescription failed (0x%08x)\n", r);
426 lok_todo_4(0x1, lstrcmp(buffer, desc->description)==0,
427 "GetDescription returned '%s' instead of '%s'\n",
428 buffer, desc->description);
432 strcpy(buffer,"garbage");
433 r = IShellLinkA_GetWorkingDirectory(sl, buffer, sizeof(buffer));
434 lok(SUCCEEDED(r), "GetWorkingDirectory failed (0x%08x)\n", r);
435 lok_todo_4(0x2, lstrcmpi(buffer, desc->workdir)==0,
436 "GetWorkingDirectory returned '%s' instead of '%s'\n",
437 buffer, desc->workdir);
441 strcpy(buffer,"garbage");
442 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
443 lok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
444 lok_todo_4(0x4, lstrcmpi(buffer, desc->path)==0,
445 "GetPath returned '%s' instead of '%s'\n",
450 LPITEMIDLIST pidl=NULL;
451 r = IShellLinkA_GetIDList(sl, &pidl);
452 lok(SUCCEEDED(r), "GetIDList failed (0x%08x)\n", r);
453 lok_todo_2(0x8, pILIsEqual(pidl, desc->pidl),
454 "GetIDList returned an incorrect pidl\n");
459 r = IShellLinkA_GetShowCmd(sl, &i);
460 lok(SUCCEEDED(r), "GetShowCmd failed (0x%08x)\n", r);
461 lok_todo_4(0x10, i==desc->showcmd,
462 "GetShowCmd returned 0x%0x instead of 0x%0x\n",
468 strcpy(buffer,"garbage");
469 r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
470 lok(SUCCEEDED(r), "GetIconLocation failed (0x%08x)\n", r);
471 lok_todo_4(0x20, lstrcmpi(buffer, desc->icon)==0,
472 "GetIconLocation returned '%s' instead of '%s'\n",
474 lok_todo_4(0x20, i==desc->icon_id,
475 "GetIconLocation returned 0x%0x instead of 0x%0x\n",
481 r = IShellLinkA_GetHotkey(sl, &i);
482 lok(SUCCEEDED(r), "GetHotkey failed (0x%08x)\n", r);
483 lok_todo_4(0x40, i==desc->hotkey,
484 "GetHotkey returned 0x%04x instead of 0x%04x\n",
488 IShellLinkA_Release(sl);
491 static void test_load_save(void)
494 char mypath[MAX_PATH];
495 char mydir[MAX_PATH];
496 char realpath[MAX_PATH];
501 /* Save an empty .lnk file */
502 memset(&desc, 0, sizeof(desc));
503 create_lnk(lnkfile, &desc, 0);
505 /* It should come back as a bunch of empty strings */
511 check_lnk(lnkfile, &desc, 0x0);
513 /* Point a .lnk file to nonexistent files */
515 desc.workdir="c:\\Nonexitent\\work\\directory";
516 desc.path="c:\\nonexistent\\path";
520 desc.icon="c:\\nonexistent\\icon\\file";
523 create_lnk(lnkfile, &desc, 0);
524 check_lnk(lnkfile, &desc, 0x0);
526 r=GetModuleFileName(NULL, mypath, sizeof(mypath));
527 ok(r>=0 && r<sizeof(mypath), "GetModuleFileName failed (%d)\n", r);
528 strcpy(mydir, mypath);
529 p=strrchr(mydir, '\\');
533 /* Overwrite the existing lnk file and point it to existing files */
534 desc.description="test 2";
538 desc.arguments="/option1 /option2 \"Some string\"";
539 desc.showcmd=SW_SHOWNORMAL;
543 create_lnk(lnkfile, &desc, 0);
544 check_lnk(lnkfile, &desc, 0x0);
546 /* Overwrite the existing lnk file and test link to a command on the path */
547 desc.description="command on path";
549 desc.path="rundll32.exe";
551 desc.arguments="/option1 /option2 \"Some string\"";
552 desc.showcmd=SW_SHOWNORMAL;
556 create_lnk(lnkfile, &desc, 0);
557 /* Check that link is created to proper location */
558 SearchPathA( NULL, desc.path, NULL, MAX_PATH, realpath, NULL);
560 check_lnk(lnkfile, &desc, 0x0);
562 /* Create a temporary non-executable file */
563 r=GetTempPath(sizeof(mypath), mypath);
564 ok(r>=0 && r<sizeof(mypath), "GetTempPath failed (%d), err %d\n", r, GetLastError());
565 r=GetLongPathName(mypath, mydir, sizeof(mydir));
566 ok(r>=0 && r<sizeof(mydir), "GetLongPathName failed (%d), err %d\n", r, GetLastError());
567 p=strrchr(mydir, '\\');
571 strcpy(mypath, mydir);
572 strcat(mypath, "\\test.txt");
573 hf = CreateFile(mypath, GENERIC_WRITE, 0, NULL,
574 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
577 /* Overwrite the existing lnk file and test link to an existing non-executable file */
578 desc.description="non-executable file";
583 desc.showcmd=SW_SHOWNORMAL;
587 create_lnk(lnkfile, &desc, 0);
588 check_lnk(lnkfile, &desc, 0x4);
590 r = DeleteFileA(mypath);
591 ok(r, "failed to delete file %s (%d)\n", mypath, GetLastError());
593 /* FIXME: Also test saving a .lnk pointing to a pidl that cannot be
594 * represented as a path.
597 /* DeleteFileW is not implemented on Win9x */
598 r=DeleteFileA("c:\\test.lnk");
599 ok(r, "failed to delete link (%d)\n", GetLastError());
602 static void test_datalink(void)
604 static const WCHAR lnk[] = {
605 ':',':','{','9','d','b','1','1','8','6','f','-','4','0','d','f','-','1',
606 '1','d','1','-','a','a','8','c','-','0','0','c','0','4','f','b','6','7',
607 '8','6','3','}',':','{','0','0','0','1','0','4','0','9','-','7','8','E',
608 '1','-','1','1','D','2','-','B','6','0','F','-','0','0','6','0','9','7',
609 'C','9','9','8','E','7','}',':',':','{','9','d','b','1','1','8','6','e',
610 '-','4','0','d','f','-','1','1','d','1','-','a','a','8','c','-','0','0',
611 'c','0','4','f','b','6','7','8','6','3','}',':','2','6',',','!','!','g',
612 'x','s','f','(','N','g',']','q','F','`','H','{','L','s','A','C','C','E',
613 'S','S','F','i','l','e','s','>','p','l','T',']','j','I','{','j','f','(',
614 '=','1','&','L','[','-','8','1','-',']',':',':',0 };
615 static const WCHAR comp[] = {
616 '2','6',',','!','!','g','x','s','f','(','N','g',']','q','F','`','H','{',
617 'L','s','A','C','C','E','S','S','F','i','l','e','s','>','p','l','T',']',
618 'j','I','{','j','f','(','=','1','&','L','[','-','8','1','-',']',0 };
619 IShellLinkDataList *dl = NULL;
620 IShellLinkW *sl = NULL;
623 EXP_DARWIN_LINK *dar;
625 r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
626 &IID_IShellLinkW, (LPVOID*)&sl );
627 ok( r == S_OK, "no shelllink\n");
631 r = IShellLinkW_QueryInterface( sl, &_IID_IShellLinkDataList, (LPVOID*) &dl );
632 ok(r == S_OK, "no datalink interface\n");
638 r = dl->lpVtbl->GetFlags( dl, &flags );
639 ok( r == S_OK, "GetFlags failed\n");
640 ok( flags == 0, "GetFlags returned wrong flags\n");
643 r = dl->lpVtbl->CopyDataBlock( dl, EXP_DARWIN_ID_SIG, (LPVOID*) &dar );
644 ok( r == E_FAIL, "CopyDataBlock failed\n");
645 ok( dar == NULL, "should be null\n");
647 r = IShellLinkW_SetPath(sl, lnk);
648 ok(r == S_OK, "set path failed\n");
651 * The following crashes:
652 * r = dl->lpVtbl->GetFlags( dl, NULL );
656 r = dl->lpVtbl->GetFlags( dl, &flags );
657 ok( r == S_OK, "GetFlags failed\n");
658 ok( flags == (SLDF_HAS_DARWINID|SLDF_HAS_LOGO3ID),
659 "GetFlags returned wrong flags\n");
662 r = dl->lpVtbl->CopyDataBlock( dl, EXP_DARWIN_ID_SIG, (LPVOID*) &dar );
663 ok( r == S_OK, "CopyDataBlock failed\n");
665 ok( dar && ((DATABLOCK_HEADER*)dar)->dwSignature == EXP_DARWIN_ID_SIG, "signature wrong\n");
666 ok( dar && 0==lstrcmpW(dar->szwDarwinID, comp ), "signature wrong\n");
670 IUnknown_Release( dl );
671 IShellLinkW_Release( sl );
674 START_TEST(shelllink)
679 hmod = GetModuleHandle("shell32");
680 pILFree = (fnILFree) GetProcAddress(hmod, (LPSTR)155);
681 pILIsEqual = (fnILIsEqual) GetProcAddress(hmod, (LPSTR)21);
682 pSHILCreateFromPath = (fnSHILCreateFromPath) GetProcAddress(hmod, (LPSTR)28);
684 r = CoInitialize(NULL);
685 ok(SUCCEEDED(r), "CoInitialize failed (0x%08x)\n", r);