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 filesystem path or a LPITEMIDLIST (shell
21 * namespace) path for a given folder (CSIDL value).
32 #include "wine/test.h"
34 #include "shell32_test.h"
37 typedef void (WINAPI *fnILFree)(LPITEMIDLIST);
38 typedef BOOL (WINAPI *fnILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
39 typedef HRESULT (WINAPI *fnSHILCreateFromPath)(LPCWSTR, LPITEMIDLIST *,DWORD*);
41 static fnILFree pILFree;
42 static fnILIsEqual pILIsEqual;
43 static fnSHILCreateFromPath pSHILCreateFromPath;
45 static DWORD (WINAPI *pGetLongPathNameA)(LPCSTR, LPSTR, DWORD);
47 static const GUID _IID_IShellLinkDataList = {
48 0x45e2b4ae, 0xb1c3, 0x11d0,
49 { 0xb9, 0x2f, 0x00, 0xa0, 0xc9, 0x03, 0x12, 0xe1 }
52 static const WCHAR lnkfile[]= { 'C',':','\\','t','e','s','t','.','l','n','k',0 };
53 static const WCHAR notafile[]= { 'C',':','\\','n','o','n','e','x','i','s','t','e','n','t','\\','f','i','l','e',0 };
56 /* For some reason SHILCreateFromPath does not work on Win98 and
57 * SHSimpleIDListFromPathA does not work on NT4. But if we call both we
58 * get what we want on all platforms.
60 static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathAW)(LPCVOID);
62 static LPITEMIDLIST path_to_pidl(const char* path)
66 if (!pSHSimpleIDListFromPathAW)
68 HMODULE hdll=GetModuleHandleA("shell32.dll");
69 pSHSimpleIDListFromPathAW=(void*)GetProcAddress(hdll, (char*)162);
70 if (!pSHSimpleIDListFromPathAW)
71 trace("SHSimpleIDListFromPathAW not found in shell32.dll\n");
75 /* pSHSimpleIDListFromPathAW maps to A on non NT platforms */
76 if (pSHSimpleIDListFromPathAW && (GetVersion() & 0x80000000))
77 pidl=pSHSimpleIDListFromPathAW(path);
85 len=MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
86 pathW=HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
87 MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, len);
89 r=pSHILCreateFromPath(pathW, &pidl, NULL);
90 ok(SUCCEEDED(r), "SHILCreateFromPath failed (0x%08x)\n", r);
91 HeapFree(GetProcessHeap(), 0, pathW);
98 * Test manipulation of an IShellLink's properties.
101 static void test_get_set(void)
105 char mypath[MAX_PATH];
106 char buffer[INFOTIPSIZE];
107 LPITEMIDLIST pidl, tmp_pidl;
112 r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
113 &IID_IShellLinkA, (LPVOID*)&sl);
114 ok(SUCCEEDED(r), "no IID_IShellLinkA (0x%08x)\n", r);
118 /* Test Getting / Setting the description */
119 strcpy(buffer,"garbage");
120 r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
121 ok(SUCCEEDED(r), "GetDescription failed (0x%08x)\n", r);
122 ok(*buffer=='\0', "GetDescription returned '%s'\n", buffer);
124 str="Some description";
125 r = IShellLinkA_SetDescription(sl, str);
126 ok(SUCCEEDED(r), "SetDescription failed (0x%08x)\n", r);
128 strcpy(buffer,"garbage");
129 r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
130 ok(SUCCEEDED(r), "GetDescription failed (0x%08x)\n", r);
131 ok(lstrcmp(buffer,str)==0, "GetDescription returned '%s'\n", buffer);
133 /* Test Getting / Setting the work directory */
134 strcpy(buffer,"garbage");
135 r = IShellLinkA_GetWorkingDirectory(sl, buffer, sizeof(buffer));
136 ok(SUCCEEDED(r), "GetWorkingDirectory failed (0x%08x)\n", r);
137 ok(*buffer=='\0', "GetWorkingDirectory returned '%s'\n", buffer);
139 str="c:\\nonexistent\\directory";
140 r = IShellLinkA_SetWorkingDirectory(sl, str);
141 ok(SUCCEEDED(r), "SetWorkingDirectory failed (0x%08x)\n", r);
143 strcpy(buffer,"garbage");
144 r = IShellLinkA_GetWorkingDirectory(sl, buffer, sizeof(buffer));
145 ok(SUCCEEDED(r), "GetWorkingDirectory failed (0x%08x)\n", r);
146 ok(lstrcmpi(buffer,str)==0, "GetWorkingDirectory returned '%s'\n", buffer);
148 /* Test Getting / Setting the path */
149 strcpy(buffer,"garbage");
150 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
151 ok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
152 ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
154 r = IShellLinkA_SetPath(sl, "");
155 ok(r==S_OK, "SetPath failed (0x%08x)\n", r);
157 strcpy(buffer,"garbage");
158 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
159 ok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
160 ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
162 /* Win98 returns S_FALSE, but WinXP returns S_OK */
163 str="c:\\nonexistent\\file";
164 r = IShellLinkA_SetPath(sl, str);
165 ok(r==S_FALSE || r==S_OK, "SetPath failed (0x%08x)\n", r);
167 strcpy(buffer,"garbage");
168 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
169 ok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
170 ok(lstrcmpi(buffer,str)==0, "GetPath returned '%s'\n", buffer);
172 /* Get some real path to play with */
173 GetWindowsDirectoryA( mypath, sizeof(mypath)-12 );
174 strcat(mypath, "\\regedit.exe");
176 /* Test the interaction of SetPath and SetIDList */
178 r = IShellLinkA_GetIDList(sl, &tmp_pidl);
179 ok(SUCCEEDED(r), "GetIDList failed (0x%08x)\n", r);
184 strcpy(buffer,"garbage");
185 ret = SHGetPathFromIDListA(tmp_pidl, buffer);
187 ok(ret, "SHGetPathFromIDListA failed\n");
190 ok(lstrcmpi(buffer,str)==0, "GetIDList returned '%s'\n", buffer);
193 pidl=path_to_pidl(mypath);
194 ok(pidl!=NULL, "path_to_pidl returned a NULL pidl\n");
198 r = IShellLinkA_SetIDList(sl, pidl);
199 ok(SUCCEEDED(r), "SetIDList failed (0x%08x)\n", r);
202 r = IShellLinkA_GetIDList(sl, &tmp_pidl);
203 ok(SUCCEEDED(r), "GetIDList failed (0x%08x)\n", r);
204 ok(tmp_pidl && pILIsEqual(pidl, tmp_pidl),
205 "GetIDList returned an incorrect pidl\n");
207 /* tmp_pidl is owned by IShellLink so we don't free it */
210 strcpy(buffer,"garbage");
211 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
212 ok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
214 ok(lstrcmpi(buffer, mypath)==0, "GetPath returned '%s'\n", buffer);
218 /* test path with quotes (Win98 IShellLinkA_SetPath returns S_FALSE, WinXP returns S_OK) */
219 r = IShellLinkA_SetPath(sl, "\"c:\\nonexistent\\file\"");
220 ok(r==S_FALSE || r == S_OK, "SetPath failed (0x%08x)\n", r);
222 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
223 ok(r==S_OK, "GetPath failed (0x%08x)\n", r);
224 ok(!lstrcmp(buffer, "C:\\nonexistent\\file"), "case doesn't match\n");
226 r = IShellLinkA_SetPath(sl, "\"c:\\foo");
227 ok(r==S_FALSE || r == S_OK, "SetPath failed (0x%08x)\n", r);
229 r = IShellLinkA_SetPath(sl, "\"\"c:\\foo");
230 ok(r==S_FALSE || r == S_OK, "SetPath failed (0x%08x)\n", r);
232 r = IShellLinkA_SetPath(sl, "c:\\foo\"");
233 ok(r==S_FALSE || r == S_OK, "SetPath failed (0x%08x)\n", r);
235 r = IShellLinkA_SetPath(sl, "\"\"c:\\foo\"");
236 ok(r==S_FALSE || r == S_OK, "SetPath failed (0x%08x)\n", r);
238 r = IShellLinkA_SetPath(sl, "\"\"c:\\foo\"\"");
239 ok(r==S_FALSE || r == S_OK, "SetPath failed (0x%08x)\n", r);
241 /* Test Getting / Setting the arguments */
242 strcpy(buffer,"garbage");
243 r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
244 ok(SUCCEEDED(r), "GetArguments failed (0x%08x)\n", r);
245 ok(*buffer=='\0', "GetArguments returned '%s'\n", buffer);
247 str="param1 \"spaced param2\"";
248 r = IShellLinkA_SetArguments(sl, str);
249 ok(SUCCEEDED(r), "SetArguments failed (0x%08x)\n", r);
251 strcpy(buffer,"garbage");
252 r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
253 ok(SUCCEEDED(r), "GetArguments failed (0x%08x)\n", r);
254 ok(lstrcmp(buffer,str)==0, "GetArguments returned '%s'\n", buffer);
256 /* Test Getting / Setting showcmd */
258 r = IShellLinkA_GetShowCmd(sl, &i);
259 ok(SUCCEEDED(r), "GetShowCmd failed (0x%08x)\n", r);
260 ok(i==SW_SHOWNORMAL, "GetShowCmd returned %d\n", i);
262 r = IShellLinkA_SetShowCmd(sl, SW_SHOWMAXIMIZED);
263 ok(SUCCEEDED(r), "SetShowCmd failed (0x%08x)\n", r);
266 r = IShellLinkA_GetShowCmd(sl, &i);
267 ok(SUCCEEDED(r), "GetShowCmd failed (0x%08x)\n", r);
268 ok(i==SW_SHOWMAXIMIZED, "GetShowCmd returned %d'\n", i);
270 /* Test Getting / Setting the icon */
272 strcpy(buffer,"garbage");
273 r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
275 ok(SUCCEEDED(r), "GetIconLocation failed (0x%08x)\n", r);
277 ok(*buffer=='\0', "GetIconLocation returned '%s'\n", buffer);
278 ok(i==0, "GetIconLocation returned %d\n", i);
280 str="c:\\nonexistent\\file";
281 r = IShellLinkA_SetIconLocation(sl, str, 0xbabecafe);
282 ok(SUCCEEDED(r), "SetIconLocation failed (0x%08x)\n", r);
285 r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
286 ok(SUCCEEDED(r), "GetIconLocation failed (0x%08x)\n", r);
287 ok(lstrcmpi(buffer,str)==0, "GetIconLocation returned '%s'\n", buffer);
288 ok(i==0xbabecafe, "GetIconLocation returned %d'\n", i);
290 /* Test Getting / Setting the hot key */
292 r = IShellLinkA_GetHotkey(sl, &w);
293 ok(SUCCEEDED(r), "GetHotkey failed (0x%08x)\n", r);
294 ok(w==0, "GetHotkey returned %d\n", w);
296 r = IShellLinkA_SetHotkey(sl, 0x5678);
297 ok(SUCCEEDED(r), "SetHotkey failed (0x%08x)\n", r);
300 r = IShellLinkA_GetHotkey(sl, &w);
301 ok(SUCCEEDED(r), "GetHotkey failed (0x%08x)\n", r);
302 ok(w==0x5678, "GetHotkey returned %d'\n", w);
304 IShellLinkA_Release(sl);
309 * Test saving and loading .lnk files
312 #define lok ok_(__FILE__, line)
313 #define lok_todo_4(todo_flag,a,b,c,d) \
314 if ((todo & todo_flag) == 0) lok((a), (b), (c), (d)); \
315 else todo_wine lok((a), (b), (c), (d));
316 #define lok_todo_2(todo_flag,a,b) \
317 if ((todo & todo_flag) == 0) lok((a), (b)); \
318 else todo_wine lok((a), (b));
319 #define check_lnk(a,b,c) check_lnk_(__LINE__, (a), (b), (c))
321 void create_lnk_(int line, const WCHAR* path, lnk_desc_t* desc, int save_fails)
327 r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
328 &IID_IShellLinkA, (LPVOID*)&sl);
329 lok(SUCCEEDED(r), "no IID_IShellLinkA (0x%08x)\n", r);
333 if (desc->description)
335 r = IShellLinkA_SetDescription(sl, desc->description);
336 lok(SUCCEEDED(r), "SetDescription failed (0x%08x)\n", r);
340 r = IShellLinkA_SetWorkingDirectory(sl, desc->workdir);
341 lok(SUCCEEDED(r), "SetWorkingDirectory failed (0x%08x)\n", r);
345 r = IShellLinkA_SetPath(sl, desc->path);
346 lok(SUCCEEDED(r), "SetPath failed (0x%08x)\n", r);
350 r = IShellLinkA_SetIDList(sl, desc->pidl);
351 lok(SUCCEEDED(r), "SetIDList failed (0x%08x)\n", r);
355 r = IShellLinkA_SetArguments(sl, desc->arguments);
356 lok(SUCCEEDED(r), "SetArguments failed (0x%08x)\n", r);
360 r = IShellLinkA_SetShowCmd(sl, desc->showcmd);
361 lok(SUCCEEDED(r), "SetShowCmd failed (0x%08x)\n", r);
365 r = IShellLinkA_SetIconLocation(sl, desc->icon, desc->icon_id);
366 lok(SUCCEEDED(r), "SetIconLocation failed (0x%08x)\n", r);
370 r = IShellLinkA_SetHotkey(sl, desc->hotkey);
371 lok(SUCCEEDED(r), "SetHotkey failed (0x%08x)\n", r);
374 r = IShellLinkW_QueryInterface(sl, &IID_IPersistFile, (LPVOID*)&pf);
375 lok(SUCCEEDED(r), "no IID_IPersistFile (0x%08x)\n", r);
378 r = IPersistFile_Save(pf, path, TRUE);
382 lok(SUCCEEDED(r), "save failed (0x%08x)\n", r);
387 lok(SUCCEEDED(r), "save failed (0x%08x)\n", r);
389 IPersistFile_Release(pf);
392 IShellLinkA_Release(sl);
395 static void check_lnk_(int line, const WCHAR* path, lnk_desc_t* desc, int todo)
400 char buffer[INFOTIPSIZE];
402 r = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
403 &IID_IShellLinkA, (LPVOID*)&sl);
404 lok(SUCCEEDED(r), "no IID_IShellLinkA (0x%08x)\n", r);
408 r = IShellLinkA_QueryInterface(sl, &IID_IPersistFile, (LPVOID*)&pf);
409 lok(SUCCEEDED(r), "no IID_IPersistFile (0x%08x)\n", r);
412 IShellLinkA_Release(sl);
416 r = IPersistFile_Load(pf, path, STGM_READ);
417 lok(SUCCEEDED(r), "load failed (0x%08x)\n", r);
418 IPersistFile_Release(pf);
421 IShellLinkA_Release(sl);
425 if (desc->description)
427 strcpy(buffer,"garbage");
428 r = IShellLinkA_GetDescription(sl, buffer, sizeof(buffer));
429 lok(SUCCEEDED(r), "GetDescription failed (0x%08x)\n", r);
430 lok_todo_4(0x1, lstrcmp(buffer, desc->description)==0,
431 "GetDescription returned '%s' instead of '%s'\n",
432 buffer, desc->description);
436 strcpy(buffer,"garbage");
437 r = IShellLinkA_GetWorkingDirectory(sl, buffer, sizeof(buffer));
438 lok(SUCCEEDED(r), "GetWorkingDirectory failed (0x%08x)\n", r);
439 lok_todo_4(0x2, lstrcmpi(buffer, desc->workdir)==0,
440 "GetWorkingDirectory returned '%s' instead of '%s'\n",
441 buffer, desc->workdir);
445 strcpy(buffer,"garbage");
446 r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
447 lok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
448 lok_todo_4(0x4, lstrcmpi(buffer, desc->path)==0,
449 "GetPath returned '%s' instead of '%s'\n",
454 LPITEMIDLIST pidl=NULL;
455 r = IShellLinkA_GetIDList(sl, &pidl);
456 lok(SUCCEEDED(r), "GetIDList failed (0x%08x)\n", r);
457 lok_todo_2(0x8, pILIsEqual(pidl, desc->pidl),
458 "GetIDList returned an incorrect pidl\n");
463 r = IShellLinkA_GetShowCmd(sl, &i);
464 lok(SUCCEEDED(r), "GetShowCmd failed (0x%08x)\n", r);
465 lok_todo_4(0x10, i==desc->showcmd,
466 "GetShowCmd returned 0x%0x instead of 0x%0x\n",
472 strcpy(buffer,"garbage");
473 r = IShellLinkA_GetIconLocation(sl, buffer, sizeof(buffer), &i);
474 lok(SUCCEEDED(r), "GetIconLocation failed (0x%08x)\n", r);
475 lok_todo_4(0x20, lstrcmpi(buffer, desc->icon)==0,
476 "GetIconLocation returned '%s' instead of '%s'\n",
478 lok_todo_4(0x20, i==desc->icon_id,
479 "GetIconLocation returned 0x%0x instead of 0x%0x\n",
485 r = IShellLinkA_GetHotkey(sl, &i);
486 lok(SUCCEEDED(r), "GetHotkey failed (0x%08x)\n", r);
487 lok_todo_4(0x40, i==desc->hotkey,
488 "GetHotkey returned 0x%04x instead of 0x%04x\n",
492 IShellLinkA_Release(sl);
495 static void test_load_save(void)
498 char mypath[MAX_PATH];
499 char mydir[MAX_PATH];
500 char realpath[MAX_PATH];
505 if (!pGetLongPathNameA)
507 skip("GetLongPathNameA is not available\n");
511 /* Save an empty .lnk file */
512 memset(&desc, 0, sizeof(desc));
513 create_lnk(lnkfile, &desc, 0);
515 /* It should come back as a bunch of empty strings */
521 check_lnk(lnkfile, &desc, 0x0);
523 /* Point a .lnk file to nonexistent files */
525 desc.workdir="c:\\Nonexitent\\work\\directory";
526 desc.path="c:\\nonexistent\\path";
530 desc.icon="c:\\nonexistent\\icon\\file";
533 create_lnk(lnkfile, &desc, 0);
534 check_lnk(lnkfile, &desc, 0x0);
536 r=GetModuleFileName(NULL, mypath, sizeof(mypath));
537 ok(r<sizeof(mypath), "GetModuleFileName failed (%d)\n", r);
538 strcpy(mydir, mypath);
539 p=strrchr(mydir, '\\');
543 /* IShellLink returns path in long form */
544 if (!pGetLongPathNameA(mypath, realpath, MAX_PATH)) strcpy( realpath, mypath );
546 /* Overwrite the existing lnk file and point it to existing files */
547 desc.description="test 2";
551 desc.arguments="/option1 /option2 \"Some string\"";
552 desc.showcmd=SW_SHOWNORMAL;
556 create_lnk(lnkfile, &desc, 0);
557 check_lnk(lnkfile, &desc, 0x0);
559 /* Overwrite the existing lnk file and test link to a command on the path */
560 desc.description="command on path";
562 desc.path="rundll32.exe";
564 desc.arguments="/option1 /option2 \"Some string\"";
565 desc.showcmd=SW_SHOWNORMAL;
569 create_lnk(lnkfile, &desc, 0);
570 /* Check that link is created to proper location */
571 SearchPathA( NULL, desc.path, NULL, MAX_PATH, realpath, NULL);
573 check_lnk(lnkfile, &desc, 0x0);
575 /* Create a temporary non-executable file */
576 r=GetTempPath(sizeof(mypath), mypath);
577 ok(r<sizeof(mypath), "GetTempPath failed (%d), err %d\n", r, GetLastError());
578 r=pGetLongPathNameA(mypath, mydir, sizeof(mydir));
579 ok(r<sizeof(mydir), "GetLongPathName failed (%d), err %d\n", r, GetLastError());
580 p=strrchr(mydir, '\\');
584 strcpy(mypath, mydir);
585 strcat(mypath, "\\test.txt");
586 hf = CreateFile(mypath, GENERIC_WRITE, 0, NULL,
587 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
590 /* Overwrite the existing lnk file and test link to an existing non-executable file */
591 desc.description="non-executable file";
596 desc.showcmd=SW_SHOWNORMAL;
600 create_lnk(lnkfile, &desc, 0);
601 check_lnk(lnkfile, &desc, 0x0);
603 r = DeleteFileA(mypath);
604 ok(r, "failed to delete file %s (%d)\n", mypath, GetLastError());
606 /* FIXME: Also test saving a .lnk pointing to a pidl that cannot be
607 * represented as a path.
610 /* DeleteFileW is not implemented on Win9x */
611 r=DeleteFileA("c:\\test.lnk");
612 ok(r, "failed to delete link (%d)\n", GetLastError());
615 static void test_datalink(void)
617 static const WCHAR lnk[] = {
618 ':',':','{','9','d','b','1','1','8','6','f','-','4','0','d','f','-','1',
619 '1','d','1','-','a','a','8','c','-','0','0','c','0','4','f','b','6','7',
620 '8','6','3','}',':','{','0','0','0','1','0','4','0','9','-','7','8','E',
621 '1','-','1','1','D','2','-','B','6','0','F','-','0','0','6','0','9','7',
622 'C','9','9','8','E','7','}',':',':','{','9','d','b','1','1','8','6','e',
623 '-','4','0','d','f','-','1','1','d','1','-','a','a','8','c','-','0','0',
624 'c','0','4','f','b','6','7','8','6','3','}',':','2','6',',','!','!','g',
625 'x','s','f','(','N','g',']','q','F','`','H','{','L','s','A','C','C','E',
626 'S','S','F','i','l','e','s','>','p','l','T',']','j','I','{','j','f','(',
627 '=','1','&','L','[','-','8','1','-',']',':',':',0 };
628 static const WCHAR comp[] = {
629 '2','6',',','!','!','g','x','s','f','(','N','g',']','q','F','`','H','{',
630 'L','s','A','C','C','E','S','S','F','i','l','e','s','>','p','l','T',']',
631 'j','I','{','j','f','(','=','1','&','L','[','-','8','1','-',']',0 };
632 IShellLinkDataList *dl = NULL;
633 IShellLinkW *sl = NULL;
636 EXP_DARWIN_LINK *dar;
638 r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
639 &IID_IShellLinkW, (LPVOID*)&sl );
640 ok( r == S_OK || r == E_NOINTERFACE, "CoCreateInstance failed (0x%08x)\n", r);
643 skip("no shelllink\n");
647 r = IShellLinkW_QueryInterface( sl, &_IID_IShellLinkDataList, (LPVOID*) &dl );
648 ok(r == S_OK, "IShellLinkW_QueryInterface failed (0x%08x)\n", r);
652 skip("no datalink interface\n");
657 r = IShellLinkDataList_GetFlags( dl, &flags );
658 ok( r == S_OK, "GetFlags failed\n");
659 ok( flags == 0, "GetFlags returned wrong flags\n");
662 r = IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG, (LPVOID*) &dar );
663 ok( r == E_FAIL, "CopyDataBlock failed\n");
664 ok( dar == NULL, "should be null\n");
666 r = IShellLinkW_SetPath(sl, lnk);
667 ok(r == S_OK, "set path failed\n");
670 * The following crashes:
671 * r = IShellLinkDataList_GetFlags( dl, NULL );
675 r = IShellLinkDataList_GetFlags( dl, &flags );
676 ok( r == S_OK, "GetFlags failed\n");
677 ok( flags == (SLDF_HAS_DARWINID|SLDF_HAS_LOGO3ID),
678 "GetFlags returned wrong flags\n");
681 r = IShellLinkDataList_CopyDataBlock( dl, EXP_DARWIN_ID_SIG, (LPVOID*) &dar );
682 ok( r == S_OK, "CopyDataBlock failed\n");
684 ok( dar && ((DATABLOCK_HEADER*)dar)->dwSignature == EXP_DARWIN_ID_SIG, "signature wrong\n");
685 ok( dar && 0==lstrcmpW(dar->szwDarwinID, comp ), "signature wrong\n");
689 IUnknown_Release( dl );
690 IShellLinkW_Release( sl );
693 START_TEST(shelllink)
696 HMODULE hmod = GetModuleHandleA("shell32.dll");
697 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
699 pILFree = (fnILFree) GetProcAddress(hmod, (LPSTR)155);
700 pILIsEqual = (fnILIsEqual) GetProcAddress(hmod, (LPSTR)21);
701 pSHILCreateFromPath = (fnSHILCreateFromPath) GetProcAddress(hmod, (LPSTR)28);
703 pGetLongPathNameA = (void *)GetProcAddress(hkernel32, "GetLongPathNameA");
705 r = CoInitialize(NULL);
706 ok(SUCCEEDED(r), "CoInitialize failed (0x%08x)\n", r);