Revised shell link process to treat empty (e.g. "") strings
[wine/hacks.git] / dlls / shell32 / shelllink.c
blob5835c1b7800fd335c427625472b1169d53d5d547
1 /*
3 * Copyright 1997 Marcus Meissner
4 * Copyright 1998 Juergen Schmied
6 */
8 #include "config.h"
10 #include <string.h>
11 #include <sys/stat.h>
12 #include <stdio.h>
13 #include <unistd.h>
14 #include <errno.h>
15 #ifdef HAVE_SYS_WAIT_H
16 # include <sys/wait.h>
17 #endif
18 #include "debugtools.h"
19 #include "winerror.h"
20 #include "winbase.h"
21 #include "winnls.h"
22 #include "winreg.h"
24 #include "shlobj.h"
25 #include "wine/undocshell.h"
26 #include "bitmaps/wine.xpm"
28 #include "heap.h"
29 #include "pidl.h"
30 #include "shell32_main.h"
31 #include "shlguid.h"
33 DEFAULT_DEBUG_CHANNEL(shell);
35 /* link file formats */
37 #include "pshpack1.h"
39 /* flag1: lnk elements: simple link has 0x0B */
40 #define WORKDIR 0x10
41 #define ARGUMENT 0x20
42 #define ICON 0x40
43 #define UNC 0x80
45 /* fStartup */
46 #define NORMAL 0x01
47 #define MAXIMIZED 0x03
48 #define MINIMIZED 0x07
50 typedef struct _LINK_HEADER
51 { DWORD MagicStr; /* 0x00 'L','\0','\0','\0' */
52 GUID MagicGuid; /* 0x04 is CLSID_ShellLink */
53 DWORD Flag1; /* 0x14 describes elements following */
54 DWORD Flag2; /* 0x18 */
55 FILETIME Time1; /* 0x1c */
56 FILETIME Time2; /* 0x24 */
57 FILETIME Time3; /* 0x2c */
58 DWORD Unknown1; /* 0x34 */
59 DWORD Unknown2; /* 0x38 icon number */
60 DWORD fStartup; /* 0x3c startup type */
61 DWORD wHotKey; /* 0x40 hotkey */
62 DWORD Unknown5; /* 0x44 */
63 DWORD Unknown6; /* 0x48 */
64 USHORT PidlSize; /* 0x4c */
65 ITEMIDLIST Pidl; /* 0x4e */
66 } LINK_HEADER, * PLINK_HEADER;
68 #define LINK_HEADER_SIZE (sizeof(LINK_HEADER)-sizeof(ITEMIDLIST))
70 typedef struct
72 BYTE bWidth;
73 BYTE bHeight;
74 BYTE bColorCount;
75 BYTE bReserved;
76 WORD wPlanes;
77 WORD wBitCount;
78 DWORD dwBytesInRes;
79 WORD nID;
80 } GRPICONDIRENTRY;
82 typedef struct
84 WORD idReserved;
85 WORD idType;
86 WORD idCount;
87 GRPICONDIRENTRY idEntries[1];
88 } GRPICONDIR;
90 typedef struct
92 BYTE bWidth;
93 BYTE bHeight;
94 BYTE bColorCount;
95 BYTE bReserved;
96 WORD wPlanes;
97 WORD wBitCount;
98 DWORD dwBytesInRes;
99 DWORD dwImageOffset;
100 } ICONDIRENTRY;
102 typedef struct
104 WORD idReserved;
105 WORD idType;
106 WORD idCount;
107 } ICONDIR;
110 #include "poppack.h"
113 static ICOM_VTABLE(IShellLinkA) slvt;
114 static ICOM_VTABLE(IShellLinkW) slvtw;
115 static ICOM_VTABLE(IPersistFile) pfvt;
116 static ICOM_VTABLE(IPersistStream) psvt;
118 /* IShellLink Implementation */
120 typedef struct
122 ICOM_VFIELD(IShellLinkA);
123 DWORD ref;
125 ICOM_VTABLE(IShellLinkW)* lpvtblw;
126 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
127 ICOM_VTABLE(IPersistStream)* lpvtblPersistStream;
129 /* internal stream of the IPersistFile interface */
130 IStream* lpFileStream;
132 /* data structures according to the informations in the lnk */
133 LPSTR sPath;
134 LPITEMIDLIST pPidl;
135 WORD wHotKey;
136 SYSTEMTIME time1;
137 SYSTEMTIME time2;
138 SYSTEMTIME time3;
140 LPSTR sIcoPath;
141 INT iIcoNdx;
142 LPSTR sArgs;
143 LPSTR sWorkDir;
144 LPSTR sDescription;
145 } IShellLinkImpl;
147 #define _IShellLinkW_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblw)))
148 #define _ICOM_THIS_From_IShellLinkW(class, name) class* This = (class*)(((char*)name)-_IShellLinkW_Offset);
150 #define _IPersistFile_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistFile)))
151 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
153 #define _IPersistStream_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistStream)))
154 #define _ICOM_THIS_From_IPersistStream(class, name) class* This = (class*)(((char*)name)-_IPersistStream_Offset);
155 #define _IPersistStream_From_ICOM_THIS(class, name) class* StreamThis = (class*)(((char*)name)+_IPersistStream_Offset);
157 /**************************************************************************
158 * IPersistFile_QueryInterface
160 static HRESULT WINAPI IPersistFile_fnQueryInterface(
161 IPersistFile* iface,
162 REFIID riid,
163 LPVOID *ppvObj)
165 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
167 TRACE("(%p)\n",This);
169 return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
172 /******************************************************************************
173 * IPersistFile_AddRef
175 static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile* iface)
177 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
179 TRACE("(%p)->(count=%lu)\n",This,This->ref);
181 return IShellLinkA_AddRef((IShellLinkA*)This);
183 /******************************************************************************
184 * IPersistFile_Release
186 static ULONG WINAPI IPersistFile_fnRelease(IPersistFile* iface)
188 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
190 TRACE("(%p)->(count=%lu)\n",This,This->ref);
192 return IShellLinkA_Release((IShellLinkA*)This);
195 static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile* iface, CLSID *pClassID)
197 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
198 FIXME("(%p)\n",This);
199 return NOERROR;
201 static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile* iface)
203 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
204 FIXME("(%p)\n",This);
205 return NOERROR;
207 static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
209 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
210 _IPersistStream_From_ICOM_THIS(IPersistStream, This)
212 LPSTR sFile = HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName);
213 HRESULT hRet = E_FAIL;
215 TRACE("(%p, %s)\n",This, sFile);
218 if (This->lpFileStream)
219 IStream_Release(This->lpFileStream);
221 if SUCCEEDED(CreateStreamOnFile(sFile, &(This->lpFileStream)))
223 if SUCCEEDED (IPersistStream_Load(StreamThis, This->lpFileStream))
225 return NOERROR;
229 return hRet;
233 /* Icon extraction routines
235 * FIXME: should use PrivateExtractIcons and friends
236 * FIXME: should not use stdio
239 static BOOL SaveIconResAsXPM(const BITMAPINFO *pIcon, const char *szXPMFileName)
241 FILE *fXPMFile;
242 int nHeight;
243 int nXORWidthBytes;
244 int nANDWidthBytes;
245 BOOL b8BitColors;
246 int nColors;
247 BYTE *pXOR;
248 BYTE *pAND;
249 BOOL aColorUsed[256] = {0};
250 int nColorsUsed = 0;
251 int i,j;
253 if (!((pIcon->bmiHeader.biBitCount == 4) || (pIcon->bmiHeader.biBitCount == 8)))
254 return 0;
256 if (!(fXPMFile = fopen(szXPMFileName, "w")))
257 return 0;
259 nHeight = pIcon->bmiHeader.biHeight / 2;
260 nXORWidthBytes = 4 * ((pIcon->bmiHeader.biWidth * pIcon->bmiHeader.biBitCount / 32)
261 + ((pIcon->bmiHeader.biWidth * pIcon->bmiHeader.biBitCount % 32) > 0));
262 nANDWidthBytes = 4 * ((pIcon->bmiHeader.biWidth / 32)
263 + ((pIcon->bmiHeader.biWidth % 32) > 0));
264 b8BitColors = pIcon->bmiHeader.biBitCount == 8;
265 nColors = pIcon->bmiHeader.biClrUsed ? pIcon->bmiHeader.biClrUsed
266 : 1 << pIcon->bmiHeader.biBitCount;
267 pXOR = (BYTE*) pIcon + sizeof (BITMAPINFOHEADER) + (nColors * sizeof (RGBQUAD));
268 pAND = pXOR + nHeight * nXORWidthBytes;
270 #define MASK(x,y) (pAND[(x) / 8 + (nHeight - (y) - 1) * nANDWidthBytes] & (1 << (7 - (x) % 8)))
271 #define COLOR(x,y) (b8BitColors ? pXOR[(x) + (nHeight - (y) - 1) * nXORWidthBytes] : (x) % 2 ? pXOR[(x) / 2 + (nHeight - (y) - 1) * nXORWidthBytes] & 0xF : (pXOR[(x) / 2 + (nHeight - (y) - 1) * nXORWidthBytes] & 0xF0) >> 4)
273 for (i = 0; i < nHeight; i++)
274 for (j = 0; j < pIcon->bmiHeader.biWidth; j++)
275 if (!aColorUsed[COLOR(j,i)] && !MASK(j,i))
277 aColorUsed[COLOR(j,i)] = TRUE;
278 nColorsUsed++;
281 if (fprintf(fXPMFile, "/* XPM */\nstatic char *icon[] = {\n") <= 0)
282 goto error;
283 if (fprintf(fXPMFile, "\"%d %d %d %d\",\n",
284 (int) pIcon->bmiHeader.biWidth, nHeight, nColorsUsed + 1, 2) <=0)
285 goto error;
287 for (i = 0; i < nColors; i++)
288 if (aColorUsed[i])
289 if (fprintf(fXPMFile, "\"%.2X c #%.2X%.2X%.2X\",\n", i, pIcon->bmiColors[i].rgbRed,
290 pIcon->bmiColors[i].rgbGreen, pIcon->bmiColors[i].rgbBlue) <= 0)
291 goto error;
292 if (fprintf(fXPMFile, "\" c None\"") <= 0)
293 goto error;
295 for (i = 0; i < nHeight; i++)
297 if (fprintf(fXPMFile, ",\n\"") <= 0)
298 goto error;
299 for (j = 0; j < pIcon->bmiHeader.biWidth; j++)
301 if MASK(j,i)
303 if (fprintf(fXPMFile, " ") <= 0)
304 goto error;
306 else
307 if (fprintf(fXPMFile, "%.2X", COLOR(j,i)) <= 0)
308 goto error;
310 if (fprintf(fXPMFile, "\"") <= 0)
311 goto error;
313 if (fprintf(fXPMFile, "};\n") <= 0)
314 goto error;
316 #undef MASK
317 #undef COLOR
319 fclose(fXPMFile);
320 return 1;
322 error:
323 fclose(fXPMFile);
324 unlink( szXPMFileName );
325 return 0;
328 static BOOL CALLBACK EnumResNameProc(HANDLE hModule, const char *lpszType, char *lpszName, LONG lParam)
330 *(HRSRC *) lParam = FindResourceA(hModule, lpszName, RT_GROUP_ICONA);
331 return FALSE;
334 static int ExtractFromEXEDLL(const char *szFileName, int nIndex, const char *szXPMFileName)
336 HMODULE hModule;
337 HRSRC hResInfo;
338 char *lpName = NULL;
339 HGLOBAL hResData;
340 GRPICONDIR *pIconDir;
341 BITMAPINFO *pIcon;
342 int nMax = 0;
343 int i;
345 if (!(hModule = LoadLibraryExA(szFileName, 0, LOAD_LIBRARY_AS_DATAFILE)))
347 TRACE("LoadLibraryExA (%s) failed, error %ld\n", szFileName, GetLastError());
348 goto error1;
351 if (nIndex)
353 hResInfo = FindResourceA(hModule, MAKEINTRESOURCEA(nIndex), RT_GROUP_ICONA);
354 TRACE("FindResourceA (%s) called, return 0x%x, error %ld\n", szFileName, hResInfo, GetLastError());
356 else
357 if (EnumResourceNamesA(hModule, RT_GROUP_ICONA, &EnumResNameProc, (LONG) &hResInfo))
359 TRACE("EnumResourceNamesA failed, error %ld\n", GetLastError());
360 goto error2;
363 if (!hResInfo)
365 TRACE("ExtractFromEXEDLL failed, error %ld\n", GetLastError());
366 goto error2;
369 if (!(hResData = LoadResource(hModule, hResInfo)))
371 TRACE("LoadResource failed, error %ld\n", GetLastError());
372 goto error2;
374 if (!(pIconDir = LockResource(hResData)))
376 TRACE("LockResource failed, error %ld\n", GetLastError());
377 goto error3;
380 for (i = 0; i < pIconDir->idCount; i++)
381 if ((pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth) > nMax)
383 lpName = MAKEINTRESOURCEA(pIconDir->idEntries[i].nID);
384 nMax = pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth;
387 FreeResource(hResData);
389 if (!(hResInfo = FindResourceA(hModule, lpName, RT_ICONA)))
391 TRACE("Second FindResourceA failed, error %ld\n", GetLastError());
392 goto error2;
394 if (!(hResData = LoadResource(hModule, hResInfo)))
396 TRACE("Second LoadResource failed, error %ld\n", GetLastError());
397 goto error2;
399 if (!(pIcon = LockResource(hResData)))
401 TRACE("Second LockResource failed, error %ld\n", GetLastError());
402 goto error3;
405 if(!SaveIconResAsXPM(pIcon, szXPMFileName))
407 TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
408 goto error3;
411 FreeResource(hResData);
412 FreeLibrary(hModule);
414 return 1;
416 error3:
417 FreeResource(hResData);
418 error2:
419 FreeLibrary(hModule);
420 error1:
421 return 0;
424 static int ExtractFromICO(const char *szFileName, const char *szXPMFileName)
426 FILE *fICOFile;
427 ICONDIR iconDir;
428 ICONDIRENTRY *pIconDirEntry;
429 int nMax = 0;
430 int nIndex = 0;
431 void *pIcon;
432 int i;
434 if (!(fICOFile = fopen(szFileName, "r")))
435 goto error1;
437 if (fread(&iconDir, sizeof (ICONDIR), 1, fICOFile) != 1)
438 goto error2;
439 if ((iconDir.idReserved != 0) || (iconDir.idType != 1))
440 goto error2;
442 if ((pIconDirEntry = malloc(iconDir.idCount * sizeof (ICONDIRENTRY))) == NULL)
443 goto error2;
444 if (fread(pIconDirEntry, sizeof (ICONDIRENTRY), iconDir.idCount, fICOFile) != iconDir.idCount)
445 goto error3;
447 for (i = 0; i < iconDir.idCount; i++)
448 if ((pIconDirEntry[i].bHeight * pIconDirEntry[i].bWidth) > nMax)
450 nIndex = i;
451 nMax = pIconDirEntry[i].bHeight * pIconDirEntry[i].bWidth;
453 if ((pIcon = malloc(pIconDirEntry[nIndex].dwBytesInRes)) == NULL)
454 goto error3;
455 if (fseek(fICOFile, pIconDirEntry[nIndex].dwImageOffset, SEEK_SET))
456 goto error4;
457 if (fread(pIcon, pIconDirEntry[nIndex].dwBytesInRes, 1, fICOFile) != 1)
458 goto error4;
460 if(!SaveIconResAsXPM(pIcon, szXPMFileName))
461 goto error4;
463 free(pIcon);
464 free(pIconDirEntry);
465 fclose(fICOFile);
467 return 1;
469 error4:
470 free(pIcon);
471 error3:
472 free(pIconDirEntry);
473 error2:
474 fclose(fICOFile);
475 error1:
476 return 0;
479 /* get the Unix file name for a given path, allocating the string */
480 inline static char *get_unix_file_name( const char *dos )
482 char buffer[MAX_PATH];
484 if (!wine_get_unix_file_name( dos, buffer, sizeof(buffer) )) return NULL;
485 return HEAP_strdupA( GetProcessHeap(), 0, buffer );
488 static BOOL create_default_icon( const char *filename )
490 FILE *fXPM;
491 int i;
493 if (!(fXPM = fopen(filename, "w"))) return FALSE;
494 fprintf(fXPM, "/* XPM */\nstatic char * icon[] = {");
495 for (i = 0; i < sizeof(wine_xpm)/sizeof(wine_xpm[0]); i++)
496 fprintf( fXPM, "\n\"%s\",", wine_xpm[i]);
497 fprintf( fXPM, "};\n" );
498 fclose( fXPM );
499 return TRUE;
502 /* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */
503 static char *extract_icon( const char *path, int index )
505 char *filename = HEAP_strdupA( GetProcessHeap(), 0, tmpnam(NULL) );
506 if (ExtractFromEXEDLL( path, index, filename )) return filename;
507 if (ExtractFromICO( path, filename )) return filename;
508 if (create_default_icon( filename )) return filename;
509 HeapFree( GetProcessHeap(), 0, filename );
510 return NULL;
514 static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
516 HRESULT ret = NOERROR;
517 int pid, status;
518 char buffer[MAX_PATH], buff2[MAX_PATH];
519 char *filename, *link_name, *p;
520 char *shell_link_app = NULL;
521 char *icon_name = NULL;
522 char *path_name = NULL;
523 char *work_dir = NULL;
524 BOOL bDesktop;
525 HKEY hkey;
527 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
529 TRACE("(%p)->(%s)\n",This,debugstr_w(pszFileName));
531 if (!pszFileName || !This->sPath)
532 return ERROR_UNKNOWN;
534 /* check for .exe extension */
535 if (!(p = strrchr( This->sPath, '.' ))) return NOERROR;
536 if (strchr( p, '\\' ) || strchr( p, '/' )) return NOERROR;
537 if (strcasecmp( p, ".exe" )) return NOERROR;
539 /* check if ShellLinker configured */
540 buffer[0] = 0;
541 if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine",
542 0, KEY_ALL_ACCESS, &hkey ))
544 DWORD type, count = sizeof(buffer);
545 if (RegQueryValueExA( hkey, "ShellLinker", 0, &type, buffer, &count )) buffer[0] = 0;
546 RegCloseKey( hkey );
548 if (!*buffer) return NOERROR;
549 shell_link_app = HEAP_strdupA( GetProcessHeap(), 0, buffer );
551 if (!WideCharToMultiByte( CP_ACP, 0, pszFileName, -1, buffer, sizeof(buffer), NULL, NULL))
552 return ERROR_UNKNOWN;
553 GetFullPathNameA( buffer, sizeof(buff2), buff2, NULL );
554 filename = HEAP_strdupA( GetProcessHeap(), 0, buff2 );
556 if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTUP, FALSE ))
558 /* ignore startup for now */
559 if (!strncasecmp( filename, buffer, strlen(buffer) )) goto done;
561 if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_DESKTOPDIRECTORY, FALSE ))
563 if (!strncasecmp( filename, buffer, strlen(buffer) ))
565 link_name = filename + strlen(buffer);
566 bDesktop = TRUE;
567 goto found;
570 if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTMENU, FALSE ))
572 if (!strncasecmp( filename, buffer, strlen(buffer) ))
574 link_name = filename + strlen(buffer);
575 bDesktop = FALSE;
576 goto found;
579 goto done;
581 found:
582 /* make link name a Unix name */
583 for (p = link_name; *p; p++) if (*p == '\\') *p = '/';
584 /* strip leading slashes */
585 while (*link_name == '/') link_name++;
586 /* remove extension */
587 if ((p = strrchr( link_name, '.' ))) *p = 0;
589 /* convert app path name */
590 path_name = get_unix_file_name( This->sPath );
592 /* convert app working dir */
593 if (This->sWorkDir) work_dir = get_unix_file_name( This->sWorkDir );
595 /* extract the icon */
596 if (!(icon_name = extract_icon( This->sIcoPath && strlen(This->sIcoPath) ?
597 This->sIcoPath : This->sPath,
598 This->iIcoNdx ))) goto done;
601 TRACE("linker app='%s' link='%s' mode=%s path='%s' args='%s' icon='%s' workdir='%s' descr='%s'\n",
602 shell_link_app, link_name, bDesktop ? "desktop" : "menu", path_name,
603 This->sArgs ? This->sArgs : "", icon_name, work_dir ? work_dir : "",
604 This->sDescription ? This->sDescription : "" );
606 if ((pid = fork()) == -1) goto done;
607 if (!pid)
609 int pos = 0;
610 char *argv[20];
611 argv[pos++] = shell_link_app;
612 argv[pos++] = "--link";
613 argv[pos++] = link_name;
614 argv[pos++] = "--path";
615 argv[pos++] = path_name;
616 argv[pos++] = bDesktop ? "--desktop" : "--menu";
617 if (This->sArgs && strlen(This->sArgs))
619 argv[pos++] = "--args";
620 argv[pos++] = This->sArgs;
622 if (icon_name)
624 argv[pos++] = "--icon";
625 argv[pos++] = icon_name;
627 if (This->sWorkDir && strlen(This->sWorkDir))
629 argv[pos++] = "--workdir";
630 argv[pos++] = This->sWorkDir;
632 if (This->sDescription && strlen(This->sDescription))
634 argv[pos++] = "--descr";
635 argv[pos++] = This->sDescription;
637 argv[pos] = NULL;
638 execvp( shell_link_app, argv );
639 _exit(1);
642 while (waitpid( pid, &status, 0 ) == -1)
644 if (errno != EINTR)
646 ret = ERROR_UNKNOWN;
647 goto done;
650 if (status) ret = E_ACCESSDENIED;
652 done:
653 if (icon_name) unlink( icon_name );
654 HeapFree( GetProcessHeap(), 0, shell_link_app );
655 HeapFree( GetProcessHeap(), 0, filename );
656 HeapFree( GetProcessHeap(), 0, icon_name );
657 HeapFree( GetProcessHeap(), 0, path_name );
658 HeapFree( GetProcessHeap(), 0, work_dir );
659 return ret;
662 static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
664 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
665 FIXME("(%p)->(%s)\n",This,debugstr_w(pszFileName));
666 return NOERROR;
668 static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR *ppszFileName)
670 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
671 FIXME("(%p)\n",This);
672 return NOERROR;
675 static ICOM_VTABLE(IPersistFile) pfvt =
677 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
678 IPersistFile_fnQueryInterface,
679 IPersistFile_fnAddRef,
680 IPersistFile_fnRelease,
681 IPersistFile_fnGetClassID,
682 IPersistFile_fnIsDirty,
683 IPersistFile_fnLoad,
684 IPersistFile_fnSave,
685 IPersistFile_fnSaveCompleted,
686 IPersistFile_fnGetCurFile
689 /************************************************************************
690 * IPersistStream_QueryInterface
692 static HRESULT WINAPI IPersistStream_fnQueryInterface(
693 IPersistStream* iface,
694 REFIID riid,
695 VOID** ppvoid)
697 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
699 TRACE("(%p)\n",This);
701 return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvoid);
704 /************************************************************************
705 * IPersistStream_Release
707 static ULONG WINAPI IPersistStream_fnRelease(
708 IPersistStream* iface)
710 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
712 TRACE("(%p)\n",This);
714 return IShellLinkA_Release((IShellLinkA*)This);
717 /************************************************************************
718 * IPersistStream_AddRef
720 static ULONG WINAPI IPersistStream_fnAddRef(
721 IPersistStream* iface)
723 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
725 TRACE("(%p)\n",This);
727 return IShellLinkA_AddRef((IShellLinkA*)This);
730 /************************************************************************
731 * IPersistStream_GetClassID
734 static HRESULT WINAPI IPersistStream_fnGetClassID(
735 IPersistStream* iface,
736 CLSID* pClassID)
738 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
740 TRACE("(%p)\n", This);
742 if (pClassID==0)
743 return E_POINTER;
745 /* memcpy(pClassID, &CLSID_???, sizeof(CLSID_???)); */
747 return S_OK;
750 /************************************************************************
751 * IPersistStream_IsDirty (IPersistStream)
753 static HRESULT WINAPI IPersistStream_fnIsDirty(
754 IPersistStream* iface)
756 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
758 TRACE("(%p)\n", This);
760 return S_OK;
762 /************************************************************************
763 * IPersistStream_Load (IPersistStream)
766 static HRESULT WINAPI IPersistStream_fnLoad(
767 IPersistStream* iface,
768 IStream* pLoadStream)
770 PLINK_HEADER lpLinkHeader = HeapAlloc(GetProcessHeap(), 0, LINK_HEADER_SIZE);
771 ULONG dwBytesRead;
772 DWORD ret = E_FAIL;
773 char sTemp[MAX_PATH];
775 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
777 TRACE("(%p)(%p)\n", This, pLoadStream);
779 if ( ! pLoadStream)
781 return STG_E_INVALIDPOINTER;
784 IStream_AddRef (pLoadStream);
785 if(lpLinkHeader)
787 if (SUCCEEDED(IStream_Read(pLoadStream, lpLinkHeader, LINK_HEADER_SIZE, &dwBytesRead)))
789 if ((lpLinkHeader->MagicStr == 0x0000004CL) && IsEqualIID(&lpLinkHeader->MagicGuid, &CLSID_ShellLink))
791 lpLinkHeader = HeapReAlloc(GetProcessHeap(), 0, lpLinkHeader, LINK_HEADER_SIZE+lpLinkHeader->PidlSize);
792 if (lpLinkHeader)
794 if (SUCCEEDED(IStream_Read(pLoadStream, &(lpLinkHeader->Pidl), lpLinkHeader->PidlSize, &dwBytesRead)))
796 if (pcheck (&lpLinkHeader->Pidl))
798 This->pPidl = ILClone (&lpLinkHeader->Pidl);
800 SHGetPathFromIDListA(&lpLinkHeader->Pidl, sTemp);
801 This->sPath = HEAP_strdupA ( GetProcessHeap(), 0, sTemp);
803 This->wHotKey = lpLinkHeader->wHotKey;
804 FileTimeToSystemTime (&lpLinkHeader->Time1, &This->time1);
805 FileTimeToSystemTime (&lpLinkHeader->Time2, &This->time2);
806 FileTimeToSystemTime (&lpLinkHeader->Time3, &This->time3);
807 #if 1
808 GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time1, NULL, sTemp, 256);
809 TRACE("-- time1: %s\n", sTemp);
810 GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time2, NULL, sTemp, 256);
811 TRACE("-- time1: %s\n", sTemp);
812 GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time3, NULL, sTemp, 256);
813 TRACE("-- time1: %s\n", sTemp);
814 pdump (This->pPidl);
815 #endif
816 ret = S_OK;
820 else
822 WARN("stream contains no link!\n");
827 IStream_Release (pLoadStream);
829 pdump(This->pPidl);
831 HeapFree(GetProcessHeap(), 0, lpLinkHeader);
833 return ret;
836 /************************************************************************
837 * IPersistStream_Save (IPersistStream)
839 static HRESULT WINAPI IPersistStream_fnSave(
840 IPersistStream* iface,
841 IStream* pOutStream,
842 BOOL fClearDirty)
844 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
846 TRACE("(%p) %p %x\n", This, pOutStream, fClearDirty);
848 return E_NOTIMPL;
851 /************************************************************************
852 * IPersistStream_GetSizeMax (IPersistStream)
854 static HRESULT WINAPI IPersistStream_fnGetSizeMax(
855 IPersistStream* iface,
856 ULARGE_INTEGER* pcbSize)
858 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
860 TRACE("(%p)\n", This);
862 return E_NOTIMPL;
865 static ICOM_VTABLE(IPersistStream) psvt =
867 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
868 IPersistStream_fnQueryInterface,
869 IPersistStream_fnAddRef,
870 IPersistStream_fnRelease,
871 IPersistStream_fnGetClassID,
872 IPersistStream_fnIsDirty,
873 IPersistStream_fnLoad,
874 IPersistStream_fnSave,
875 IPersistStream_fnGetSizeMax
878 /**************************************************************************
879 * IShellLink_Constructor
881 IShellLinkA * IShellLink_Constructor(BOOL bUnicode)
882 { IShellLinkImpl * sl;
884 sl = (IShellLinkImpl *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellLinkImpl));
885 sl->ref = 1;
886 ICOM_VTBL(sl) = &slvt;
887 sl->lpvtblw = &slvtw;
888 sl->lpvtblPersistFile = &pfvt;
889 sl->lpvtblPersistStream = &psvt;
891 TRACE("(%p)->()\n",sl);
892 shell32_ObjCount++;
893 return bUnicode ? (IShellLinkA *) &(sl->lpvtblw) : (IShellLinkA *)sl;
896 /**************************************************************************
897 * IShellLinkA_QueryInterface
899 static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid, LPVOID *ppvObj)
901 ICOM_THIS(IShellLinkImpl, iface);
903 TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
905 *ppvObj = NULL;
907 if(IsEqualIID(riid, &IID_IUnknown) ||
908 IsEqualIID(riid, &IID_IShellLinkA))
910 *ppvObj = This;
912 else if(IsEqualIID(riid, &IID_IShellLinkW))
914 *ppvObj = (IShellLinkW *)&(This->lpvtblw);
916 else if(IsEqualIID(riid, &IID_IPersistFile))
918 *ppvObj = (IPersistFile *)&(This->lpvtblPersistFile);
920 else if(IsEqualIID(riid, &IID_IPersistStream))
922 *ppvObj = (IPersistStream *)&(This->lpvtblPersistStream);
925 if(*ppvObj)
927 IUnknown_AddRef((IUnknown*)(*ppvObj));
928 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
929 return S_OK;
931 TRACE("-- Interface: E_NOINTERFACE\n");
932 return E_NOINTERFACE;
934 /******************************************************************************
935 * IShellLinkA_AddRef
937 static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface)
939 ICOM_THIS(IShellLinkImpl, iface);
941 TRACE("(%p)->(count=%lu)\n",This,This->ref);
943 shell32_ObjCount++;
944 return ++(This->ref);
946 /******************************************************************************
947 * IShellLinkA_Release
949 static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface)
951 ICOM_THIS(IShellLinkImpl, iface);
953 TRACE("(%p)->(count=%lu)\n",This,This->ref);
955 shell32_ObjCount--;
956 if (!--(This->ref))
957 { TRACE("-- destroying IShellLink(%p)\n",This);
959 if (This->sIcoPath)
960 HeapFree(GetProcessHeap(), 0, This->sIcoPath);
962 if (This->sArgs)
963 HeapFree(GetProcessHeap(), 0, This->sArgs);
965 if (This->sWorkDir)
966 HeapFree(GetProcessHeap(), 0, This->sWorkDir);
968 if (This->sDescription)
969 HeapFree(GetProcessHeap(), 0, This->sDescription);
971 if (This->sPath)
972 HeapFree(GetProcessHeap(),0,This->sPath);
974 if (This->pPidl)
975 SHFree(This->pPidl);
977 if (This->lpFileStream)
978 IStream_Release(This->lpFileStream);
980 This->iIcoNdx = 0;
982 HeapFree(GetProcessHeap(),0,This);
983 return 0;
985 return This->ref;
988 static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA * iface, LPSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
990 ICOM_THIS(IShellLinkImpl, iface);
992 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n",This, pszFile, cchMaxPath, pfd, fFlags, debugstr_a(This->sPath));
994 if (This->sPath)
995 lstrcpynA(pszFile,This->sPath, cchMaxPath);
996 else
997 return E_FAIL;
999 return NOERROR;
1001 static HRESULT WINAPI IShellLinkA_fnGetIDList(IShellLinkA * iface, LPITEMIDLIST * ppidl)
1003 ICOM_THIS(IShellLinkImpl, iface);
1005 TRACE("(%p)->(ppidl=%p)\n",This, ppidl);
1007 *ppidl = ILClone(This->pPidl);
1008 return NOERROR;
1010 static HRESULT WINAPI IShellLinkA_fnSetIDList(IShellLinkA * iface, LPCITEMIDLIST pidl)
1012 ICOM_THIS(IShellLinkImpl, iface);
1014 TRACE("(%p)->(pidl=%p)\n",This, pidl);
1016 if (This->pPidl)
1017 SHFree(This->pPidl);
1018 This->pPidl = ILClone (pidl);
1019 return NOERROR;
1021 static HRESULT WINAPI IShellLinkA_fnGetDescription(IShellLinkA * iface, LPSTR pszName,INT cchMaxName)
1023 ICOM_THIS(IShellLinkImpl, iface);
1025 FIXME("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
1026 lstrcpynA(pszName,"Description, FIXME",cchMaxName);
1027 return NOERROR;
1029 static HRESULT WINAPI IShellLinkA_fnSetDescription(IShellLinkA * iface, LPCSTR pszName)
1031 ICOM_THIS(IShellLinkImpl, iface);
1033 TRACE("(%p)->(pName=%s)\n", This, pszName);
1035 if (This->sDescription)
1036 HeapFree(GetProcessHeap(), 0, This->sDescription);
1037 if (!(This->sDescription = HEAP_strdupA(GetProcessHeap(), 0, pszName)))
1038 return E_OUTOFMEMORY;
1040 return NOERROR;
1042 static HRESULT WINAPI IShellLinkA_fnGetWorkingDirectory(IShellLinkA * iface, LPSTR pszDir,INT cchMaxPath)
1044 ICOM_THIS(IShellLinkImpl, iface);
1046 FIXME("(%p)->()\n",This);
1047 lstrcpynA(pszDir,"c:\\", cchMaxPath);
1048 return NOERROR;
1050 static HRESULT WINAPI IShellLinkA_fnSetWorkingDirectory(IShellLinkA * iface, LPCSTR pszDir)
1052 ICOM_THIS(IShellLinkImpl, iface);
1054 TRACE("(%p)->(dir=%s)\n",This, pszDir);
1056 if (This->sWorkDir)
1057 HeapFree(GetProcessHeap(), 0, This->sWorkDir);
1058 if (!(This->sWorkDir = HEAP_strdupA(GetProcessHeap(), 0, pszDir)))
1059 return E_OUTOFMEMORY;
1061 return NOERROR;
1063 static HRESULT WINAPI IShellLinkA_fnGetArguments(IShellLinkA * iface, LPSTR pszArgs,INT cchMaxPath)
1065 ICOM_THIS(IShellLinkImpl, iface);
1067 FIXME("(%p)->(%p len=%u)\n",This, pszArgs, cchMaxPath);
1068 lstrcpynA(pszArgs, "", cchMaxPath);
1069 return NOERROR;
1071 static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA * iface, LPCSTR pszArgs)
1073 ICOM_THIS(IShellLinkImpl, iface);
1075 TRACE("(%p)->(args=%s)\n",This, pszArgs);
1077 if (This->sArgs)
1078 HeapFree(GetProcessHeap(), 0, This->sArgs);
1079 if (!(This->sArgs = HEAP_strdupA(GetProcessHeap(), 0, pszArgs)))
1080 return E_OUTOFMEMORY;
1082 return NOERROR;
1084 static HRESULT WINAPI IShellLinkA_fnGetHotkey(IShellLinkA * iface, WORD *pwHotkey)
1086 ICOM_THIS(IShellLinkImpl, iface);
1088 TRACE("(%p)->(%p)(0x%08x)\n",This, pwHotkey, This->wHotKey);
1090 *pwHotkey = This->wHotKey;
1092 return NOERROR;
1094 static HRESULT WINAPI IShellLinkA_fnSetHotkey(IShellLinkA * iface, WORD wHotkey)
1096 ICOM_THIS(IShellLinkImpl, iface);
1098 TRACE("(%p)->(hotkey=%x)\n",This, wHotkey);
1100 This->wHotKey = wHotkey;
1102 return NOERROR;
1104 static HRESULT WINAPI IShellLinkA_fnGetShowCmd(IShellLinkA * iface, INT *piShowCmd)
1106 ICOM_THIS(IShellLinkImpl, iface);
1108 FIXME("(%p)->(%p)\n",This, piShowCmd);
1109 *piShowCmd=0;
1110 return NOERROR;
1112 static HRESULT WINAPI IShellLinkA_fnSetShowCmd(IShellLinkA * iface, INT iShowCmd)
1114 ICOM_THIS(IShellLinkImpl, iface);
1116 FIXME("(%p)->(showcmd=%x)\n",This, iShowCmd);
1117 return NOERROR;
1119 static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
1121 ICOM_THIS(IShellLinkImpl, iface);
1123 FIXME("(%p)->(%p len=%u iicon=%p)\n",This, pszIconPath, cchIconPath, piIcon);
1124 lstrcpynA(pszIconPath,"shell32.dll",cchIconPath);
1125 *piIcon=1;
1126 return NOERROR;
1128 static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath,INT iIcon)
1130 ICOM_THIS(IShellLinkImpl, iface);
1132 TRACE("(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
1134 if (This->sIcoPath)
1135 HeapFree(GetProcessHeap(), 0, This->sIcoPath);
1136 if (!(This->sIcoPath = HEAP_strdupA(GetProcessHeap(), 0, pszIconPath)))
1137 return E_OUTOFMEMORY;
1138 This->iIcoNdx = iIcon;
1140 return NOERROR;
1142 static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR pszPathRel, DWORD dwReserved)
1144 ICOM_THIS(IShellLinkImpl, iface);
1146 FIXME("(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved);
1147 return NOERROR;
1149 static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWORD fFlags)
1151 ICOM_THIS(IShellLinkImpl, iface);
1153 FIXME("(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
1154 return NOERROR;
1156 static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile)
1158 ICOM_THIS(IShellLinkImpl, iface);
1160 TRACE("(%p)->(path=%s)\n",This, pszFile);
1162 if (This->sPath)
1163 HeapFree(GetProcessHeap(), 0, This->sPath);
1164 if (!(This->sPath = HEAP_strdupA(GetProcessHeap(), 0, pszFile)))
1165 return E_OUTOFMEMORY;
1167 return NOERROR;
1170 /**************************************************************************
1171 * IShellLink Implementation
1174 static ICOM_VTABLE(IShellLinkA) slvt =
1176 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1177 IShellLinkA_fnQueryInterface,
1178 IShellLinkA_fnAddRef,
1179 IShellLinkA_fnRelease,
1180 IShellLinkA_fnGetPath,
1181 IShellLinkA_fnGetIDList,
1182 IShellLinkA_fnSetIDList,
1183 IShellLinkA_fnGetDescription,
1184 IShellLinkA_fnSetDescription,
1185 IShellLinkA_fnGetWorkingDirectory,
1186 IShellLinkA_fnSetWorkingDirectory,
1187 IShellLinkA_fnGetArguments,
1188 IShellLinkA_fnSetArguments,
1189 IShellLinkA_fnGetHotkey,
1190 IShellLinkA_fnSetHotkey,
1191 IShellLinkA_fnGetShowCmd,
1192 IShellLinkA_fnSetShowCmd,
1193 IShellLinkA_fnGetIconLocation,
1194 IShellLinkA_fnSetIconLocation,
1195 IShellLinkA_fnSetRelativePath,
1196 IShellLinkA_fnResolve,
1197 IShellLinkA_fnSetPath
1201 /**************************************************************************
1202 * IShellLinkW_fnQueryInterface
1204 static HRESULT WINAPI IShellLinkW_fnQueryInterface(
1205 IShellLinkW * iface, REFIID riid, LPVOID *ppvObj)
1207 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1209 return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
1212 /******************************************************************************
1213 * IShellLinkW_fnAddRef
1215 static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface)
1217 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1219 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1221 return IShellLinkA_AddRef((IShellLinkA*)This);
1223 /******************************************************************************
1224 * IShellLinkW_fnRelease
1227 static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
1229 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1231 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1233 return IShellLinkA_Release((IShellLinkA*)This);
1236 static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
1238 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1240 FIXME("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
1241 MultiByteToWideChar( CP_ACP, 0, "c:\\foo.bar", -1, pszFile, cchMaxPath );
1242 return NOERROR;
1245 static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl)
1247 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1249 FIXME("(%p)->(ppidl=%p)\n",This, ppidl);
1250 *ppidl = _ILCreateDesktop();
1251 return NOERROR;
1254 static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl)
1256 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1258 FIXME("(%p)->(pidl=%p)\n",This, pidl);
1259 return NOERROR;
1262 static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR pszName,INT cchMaxName)
1264 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1266 FIXME("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
1267 MultiByteToWideChar( CP_ACP, 0, "Description, FIXME", -1, pszName, cchMaxName );
1268 return NOERROR;
1271 static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR pszName)
1273 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1275 TRACE("(%p)->(desc=%s)\n",This, debugstr_w(pszName));
1277 if (This->sDescription)
1278 HeapFree(GetProcessHeap(), 0, This->sDescription);
1279 if (!(This->sDescription = HEAP_strdupWtoA(GetProcessHeap(), 0, pszName)))
1280 return E_OUTOFMEMORY;
1282 return NOERROR;
1285 static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPWSTR pszDir,INT cchMaxPath)
1287 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1289 FIXME("(%p)->()\n",This);
1290 MultiByteToWideChar( CP_ACP, 0, "c:\\", -1, pszDir, cchMaxPath );
1291 return NOERROR;
1294 static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPCWSTR pszDir)
1296 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1298 TRACE("(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
1300 if (This->sWorkDir)
1301 HeapFree(GetProcessHeap(), 0, This->sWorkDir);
1302 if (!(This->sWorkDir = HEAP_strdupWtoA(GetProcessHeap(), 0, pszDir)))
1303 return E_OUTOFMEMORY;
1305 return NOERROR;
1308 static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR pszArgs,INT cchMaxPath)
1310 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1312 FIXME("(%p)->(%p len=%u)\n",This, pszArgs, cchMaxPath);
1313 pszArgs[0] = 0;
1314 return NOERROR;
1317 static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR pszArgs)
1319 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1321 TRACE("(%p)->(args=%s)\n",This, debugstr_w(pszArgs));
1323 if (This->sArgs)
1324 HeapFree(GetProcessHeap(), 0, This->sArgs);
1325 if (!(This->sArgs = HEAP_strdupWtoA(GetProcessHeap(), 0, pszArgs)))
1326 return E_OUTOFMEMORY;
1328 return NOERROR;
1331 static HRESULT WINAPI IShellLinkW_fnGetHotkey(IShellLinkW * iface, WORD *pwHotkey)
1333 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1335 FIXME("(%p)->(%p)\n",This, pwHotkey);
1336 *pwHotkey=0x0;
1337 return NOERROR;
1340 static HRESULT WINAPI IShellLinkW_fnSetHotkey(IShellLinkW * iface, WORD wHotkey)
1342 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1344 FIXME("(%p)->(hotkey=%x)\n",This, wHotkey);
1345 return NOERROR;
1348 static HRESULT WINAPI IShellLinkW_fnGetShowCmd(IShellLinkW * iface, INT *piShowCmd)
1350 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1352 FIXME("(%p)->(%p)\n",This, piShowCmd);
1353 *piShowCmd=0;
1354 return NOERROR;
1357 static HRESULT WINAPI IShellLinkW_fnSetShowCmd(IShellLinkW * iface, INT iShowCmd)
1359 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1361 FIXME("(%p)->(showcmd=%x)\n",This, iShowCmd);
1362 return NOERROR;
1365 static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon)
1367 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1369 FIXME("(%p)->(%p len=%u iicon=%p)\n",This, pszIconPath, cchIconPath, piIcon);
1370 MultiByteToWideChar( CP_ACP, 0, "shell32.dll", -1, pszIconPath, cchIconPath );
1371 *piIcon=1;
1372 return NOERROR;
1375 static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon)
1377 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1379 TRACE("(%p)->(path=%s iicon=%u)\n",This, debugstr_w(pszIconPath), iIcon);
1381 if (This->sIcoPath)
1382 HeapFree(GetProcessHeap(), 0, This->sIcoPath);
1383 if (!(This->sIcoPath = HEAP_strdupWtoA(GetProcessHeap(), 0, pszIconPath)))
1384 return E_OUTOFMEMORY;
1385 This->iIcoNdx = iIcon;
1387 return NOERROR;
1390 static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR pszPathRel, DWORD dwReserved)
1392 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1394 FIXME("(%p)->(path=%s %lx)\n",This, debugstr_w(pszPathRel), dwReserved);
1395 return NOERROR;
1398 static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWORD fFlags)
1400 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1402 FIXME("(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
1403 return NOERROR;
1406 static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile)
1408 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1410 TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile));
1412 if (This->sPath)
1413 HeapFree(GetProcessHeap(), 0, This->sPath);
1414 if (!(This->sPath = HEAP_strdupWtoA(GetProcessHeap(), 0, pszFile)))
1415 return E_OUTOFMEMORY;
1417 return NOERROR;
1420 /**************************************************************************
1421 * IShellLinkW Implementation
1424 static ICOM_VTABLE(IShellLinkW) slvtw =
1426 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1427 IShellLinkW_fnQueryInterface,
1428 IShellLinkW_fnAddRef,
1429 IShellLinkW_fnRelease,
1430 IShellLinkW_fnGetPath,
1431 IShellLinkW_fnGetIDList,
1432 IShellLinkW_fnSetIDList,
1433 IShellLinkW_fnGetDescription,
1434 IShellLinkW_fnSetDescription,
1435 IShellLinkW_fnGetWorkingDirectory,
1436 IShellLinkW_fnSetWorkingDirectory,
1437 IShellLinkW_fnGetArguments,
1438 IShellLinkW_fnSetArguments,
1439 IShellLinkW_fnGetHotkey,
1440 IShellLinkW_fnSetHotkey,
1441 IShellLinkW_fnGetShowCmd,
1442 IShellLinkW_fnSetShowCmd,
1443 IShellLinkW_fnGetIconLocation,
1444 IShellLinkW_fnSetIconLocation,
1445 IShellLinkW_fnSetRelativePath,
1446 IShellLinkW_fnResolve,
1447 IShellLinkW_fnSetPath