3 * Copyright 1997 Marcus Meissner
4 * Copyright 1998 Juergen Schmied
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #ifdef HAVE_SYS_WAIT_H
28 # include <sys/wait.h>
30 #include "wine/debug.h"
31 #include "wine/port.h"
38 #include "undocshell.h"
39 #include "bitmaps/wine.xpm"
43 #include "shell32_main.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(shell);
48 /* link file formats */
52 /* flag1: lnk elements: simple link has 0x0B */
60 #define MAXIMIZED 0x03
61 #define MINIMIZED 0x07
63 typedef struct _LINK_HEADER
64 { DWORD MagicStr; /* 0x00 'L','\0','\0','\0' */
65 GUID MagicGuid; /* 0x04 is CLSID_ShellLink */
66 DWORD Flag1; /* 0x14 describes elements following */
67 DWORD Flag2; /* 0x18 */
68 FILETIME Time1; /* 0x1c */
69 FILETIME Time2; /* 0x24 */
70 FILETIME Time3; /* 0x2c */
71 DWORD Unknown1; /* 0x34 */
72 DWORD Unknown2; /* 0x38 icon number */
73 DWORD fStartup; /* 0x3c startup type */
74 DWORD wHotKey; /* 0x40 hotkey */
75 DWORD Unknown5; /* 0x44 */
76 DWORD Unknown6; /* 0x48 */
77 USHORT PidlSize; /* 0x4c */
78 ITEMIDLIST Pidl; /* 0x4e */
79 } LINK_HEADER, * PLINK_HEADER;
81 #define LINK_HEADER_SIZE (sizeof(LINK_HEADER)-sizeof(ITEMIDLIST))
100 GRPICONDIRENTRY idEntries[1];
131 static ICOM_VTABLE(IShellLinkA) slvt;
132 static ICOM_VTABLE(IShellLinkW) slvtw;
133 static ICOM_VTABLE(IPersistFile) pfvt;
134 static ICOM_VTABLE(IPersistStream) psvt;
136 /* IShellLink Implementation */
140 ICOM_VFIELD(IShellLinkA);
143 ICOM_VTABLE(IShellLinkW)* lpvtblw;
144 ICOM_VTABLE(IPersistFile)* lpvtblPersistFile;
145 ICOM_VTABLE(IPersistStream)* lpvtblPersistStream;
147 /* internal stream of the IPersistFile interface */
148 IStream* lpFileStream;
150 /* data structures according to the informations in the lnk */
165 #define _IShellLinkW_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblw)))
166 #define _ICOM_THIS_From_IShellLinkW(class, name) class* This = (class*)(((char*)name)-_IShellLinkW_Offset);
168 #define _IPersistFile_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistFile)))
169 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
171 #define _IPersistStream_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistStream)))
172 #define _ICOM_THIS_From_IPersistStream(class, name) class* This = (class*)(((char*)name)-_IPersistStream_Offset);
173 #define _IPersistStream_From_ICOM_THIS(class, name) class* StreamThis = (class*)(((char*)name)+_IPersistStream_Offset);
176 /* strdup on the process heap */
177 inline static LPSTR heap_strdup( LPCSTR str )
179 INT len = strlen(str) + 1;
180 LPSTR p = HeapAlloc( GetProcessHeap(), 0, len );
181 if (p) memcpy( p, str, len );
186 /**************************************************************************
187 * IPersistFile_QueryInterface
189 static HRESULT WINAPI IPersistFile_fnQueryInterface(
194 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
196 TRACE("(%p)\n",This);
198 return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
201 /******************************************************************************
202 * IPersistFile_AddRef
204 static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile* iface)
206 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
208 TRACE("(%p)->(count=%lu)\n",This,This->ref);
210 return IShellLinkA_AddRef((IShellLinkA*)This);
212 /******************************************************************************
213 * IPersistFile_Release
215 static ULONG WINAPI IPersistFile_fnRelease(IPersistFile* iface)
217 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
219 TRACE("(%p)->(count=%lu)\n",This,This->ref);
221 return IShellLinkA_Release((IShellLinkA*)This);
224 static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile* iface, CLSID *pClassID)
226 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
227 FIXME("(%p)\n",This);
230 static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile* iface)
232 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
233 FIXME("(%p)\n",This);
236 static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
238 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface)
239 _IPersistStream_From_ICOM_THIS(IPersistStream, This)
241 LPSTR sFile = HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName);
242 HRESULT hRet = E_FAIL;
244 TRACE("(%p, %s)\n",This, sFile);
247 if (This->lpFileStream)
248 IStream_Release(This->lpFileStream);
250 if SUCCEEDED(CreateStreamOnFile(sFile, &(This->lpFileStream)))
252 if SUCCEEDED (IPersistStream_Load(StreamThis, This->lpFileStream))
262 /* Icon extraction routines
264 * FIXME: should use PrivateExtractIcons and friends
265 * FIXME: should not use stdio
268 static BOOL SaveIconResAsXPM(const BITMAPINFO *pIcon, const char *szXPMFileName)
278 BOOL aColorUsed[256] = {0};
282 if (!((pIcon->bmiHeader.biBitCount == 4) || (pIcon->bmiHeader.biBitCount == 8)))
285 if (!(fXPMFile = fopen(szXPMFileName, "w")))
288 nHeight = pIcon->bmiHeader.biHeight / 2;
289 nXORWidthBytes = 4 * ((pIcon->bmiHeader.biWidth * pIcon->bmiHeader.biBitCount / 32)
290 + ((pIcon->bmiHeader.biWidth * pIcon->bmiHeader.biBitCount % 32) > 0));
291 nANDWidthBytes = 4 * ((pIcon->bmiHeader.biWidth / 32)
292 + ((pIcon->bmiHeader.biWidth % 32) > 0));
293 b8BitColors = pIcon->bmiHeader.biBitCount == 8;
294 nColors = pIcon->bmiHeader.biClrUsed ? pIcon->bmiHeader.biClrUsed
295 : 1 << pIcon->bmiHeader.biBitCount;
296 pXOR = (BYTE*) pIcon + sizeof (BITMAPINFOHEADER) + (nColors * sizeof (RGBQUAD));
297 pAND = pXOR + nHeight * nXORWidthBytes;
299 #define MASK(x,y) (pAND[(x) / 8 + (nHeight - (y) - 1) * nANDWidthBytes] & (1 << (7 - (x) % 8)))
300 #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)
302 for (i = 0; i < nHeight; i++)
303 for (j = 0; j < pIcon->bmiHeader.biWidth; j++)
304 if (!aColorUsed[COLOR(j,i)] && !MASK(j,i))
306 aColorUsed[COLOR(j,i)] = TRUE;
310 if (fprintf(fXPMFile, "/* XPM */\nstatic char *icon[] = {\n") <= 0)
312 if (fprintf(fXPMFile, "\"%d %d %d %d\",\n",
313 (int) pIcon->bmiHeader.biWidth, nHeight, nColorsUsed + 1, 2) <=0)
316 for (i = 0; i < nColors; i++)
318 if (fprintf(fXPMFile, "\"%.2X c #%.2X%.2X%.2X\",\n", i, pIcon->bmiColors[i].rgbRed,
319 pIcon->bmiColors[i].rgbGreen, pIcon->bmiColors[i].rgbBlue) <= 0)
321 if (fprintf(fXPMFile, "\" c None\"") <= 0)
324 for (i = 0; i < nHeight; i++)
326 if (fprintf(fXPMFile, ",\n\"") <= 0)
328 for (j = 0; j < pIcon->bmiHeader.biWidth; j++)
332 if (fprintf(fXPMFile, " ") <= 0)
336 if (fprintf(fXPMFile, "%.2X", COLOR(j,i)) <= 0)
339 if (fprintf(fXPMFile, "\"") <= 0)
342 if (fprintf(fXPMFile, "};\n") <= 0)
353 unlink( szXPMFileName );
357 static BOOL CALLBACK EnumResNameProc(HANDLE hModule, const char *lpszType, char *lpszName, LONG lParam)
359 ENUMRESSTRUCT *sEnumRes = (ENUMRESSTRUCT *) lParam;
361 if (!sEnumRes->nIndex--)
363 *sEnumRes->pResInfo = FindResourceA(hModule, lpszName, RT_GROUP_ICONA);
370 static int ExtractFromEXEDLL(const char *szFileName, int nIndex, const char *szXPMFileName)
376 GRPICONDIR *pIconDir;
378 ENUMRESSTRUCT sEnumRes;
383 if (!(hModule = LoadLibraryExA(szFileName, 0, LOAD_LIBRARY_AS_DATAFILE)))
385 TRACE("LoadLibraryExA (%s) failed, error %ld\n", szFileName, GetLastError());
391 hResInfo = FindResourceA(hModule, MAKEINTRESOURCEA(-nIndex), RT_GROUP_ICONA);
392 TRACE("FindResourceA (%s) called, return 0x%x, error %ld\n", szFileName, hResInfo, GetLastError());
396 sEnumRes.pResInfo = &hResInfo;
397 sEnumRes.nIndex = nIndex;
398 if (EnumResourceNamesA(hModule, RT_GROUP_ICONA, &EnumResNameProc, (LONG) &sEnumRes))
400 TRACE("EnumResourceNamesA failed, error %ld\n", GetLastError());
407 TRACE("ExtractFromEXEDLL failed, error %ld\n", GetLastError());
411 if (!(hResData = LoadResource(hModule, hResInfo)))
413 TRACE("LoadResource failed, error %ld\n", GetLastError());
416 if (!(pIconDir = LockResource(hResData)))
418 TRACE("LockResource failed, error %ld\n", GetLastError());
422 for (i = 0; i < pIconDir->idCount; i++)
423 if ((pIconDir->idEntries[i].wBitCount >= nMaxBits) && (pIconDir->idEntries[i].wBitCount <= 8))
425 if (pIconDir->idEntries[i].wBitCount > nMaxBits)
427 nMaxBits = pIconDir->idEntries[i].wBitCount;
430 if ((pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth) > nMax)
432 lpName = MAKEINTRESOURCEA(pIconDir->idEntries[i].nID);
433 nMax = pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth;
437 FreeResource(hResData);
439 if (!(hResInfo = FindResourceA(hModule, lpName, RT_ICONA)))
441 TRACE("Second FindResourceA failed, error %ld\n", GetLastError());
444 if (!(hResData = LoadResource(hModule, hResInfo)))
446 TRACE("Second LoadResource failed, error %ld\n", GetLastError());
449 if (!(pIcon = LockResource(hResData)))
451 TRACE("Second LockResource failed, error %ld\n", GetLastError());
455 if(!SaveIconResAsXPM(pIcon, szXPMFileName))
457 TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
461 FreeResource(hResData);
462 FreeLibrary(hModule);
467 FreeResource(hResData);
469 FreeLibrary(hModule);
474 static int ExtractFromICO(const char *szFileName, const char *szXPMFileName)
478 ICONDIRENTRY *pIconDirEntry;
484 if (!(fICOFile = fopen(szFileName, "r")))
487 if (fread(&iconDir, sizeof (ICONDIR), 1, fICOFile) != 1)
489 if ((iconDir.idReserved != 0) || (iconDir.idType != 1))
492 if ((pIconDirEntry = malloc(iconDir.idCount * sizeof (ICONDIRENTRY))) == NULL)
494 if (fread(pIconDirEntry, sizeof (ICONDIRENTRY), iconDir.idCount, fICOFile) != iconDir.idCount)
497 for (i = 0; i < iconDir.idCount; i++)
498 if ((pIconDirEntry[i].bHeight * pIconDirEntry[i].bWidth) > nMax)
501 nMax = pIconDirEntry[i].bHeight * pIconDirEntry[i].bWidth;
503 if ((pIcon = malloc(pIconDirEntry[nIndex].dwBytesInRes)) == NULL)
505 if (fseek(fICOFile, pIconDirEntry[nIndex].dwImageOffset, SEEK_SET))
507 if (fread(pIcon, pIconDirEntry[nIndex].dwBytesInRes, 1, fICOFile) != 1)
510 if(!SaveIconResAsXPM(pIcon, szXPMFileName))
529 /* get the Unix file name for a given path, allocating the string */
530 inline static char *get_unix_file_name( const char *dos )
532 char buffer[MAX_PATH];
534 if (!wine_get_unix_file_name( dos, buffer, sizeof(buffer) )) return NULL;
535 return heap_strdup( buffer );
538 static BOOL create_default_icon( const char *filename )
543 if (!(fXPM = fopen(filename, "w"))) return FALSE;
544 fprintf(fXPM, "/* XPM */\nstatic char * icon[] = {");
545 for (i = 0; i < sizeof(wine_xpm)/sizeof(wine_xpm[0]); i++)
546 fprintf( fXPM, "\n\"%s\",", wine_xpm[i]);
547 fprintf( fXPM, "};\n" );
552 /* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */
553 static char *extract_icon( const char *path, int index)
555 int fd, nodefault = 1;
556 char *filename, tmpfn[25];
558 strcpy(tmpfn,"/tmp/icon.XXXXXX");
559 fd = mkstemp( tmpfn );
562 filename = heap_strdup( tmpfn );
563 close(fd); /* not needed */
565 /* If icon path begins with a '*' then this is a deferred call */
571 if (ExtractFromEXEDLL( path, index, filename )) return filename;
572 if (ExtractFromICO( path, filename )) return filename;
574 if (create_default_icon( filename )) return filename;
575 HeapFree( GetProcessHeap(), 0, filename );
580 static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
582 HRESULT ret = NOERROR;
584 char buffer[MAX_PATH], buff2[MAX_PATH], ascii_filename[MAX_PATH];
585 char *filename, *link_name, *p;
586 char *shell_link_app = NULL;
587 char *icon_name = NULL;
588 char *work_dir = NULL;
592 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
594 TRACE("(%p)->(%s)\n",This,debugstr_w(pszFileName));
596 if (!pszFileName || !This->sPath)
597 return ERROR_UNKNOWN;
599 /* check for .exe extension */
600 if (!(p = strrchr( This->sPath, '.' ))) return NOERROR;
601 if (strchr( p, '\\' ) || strchr( p, '/' )) return NOERROR;
602 if (strcasecmp( p, ".exe" )) return NOERROR;
604 /* check if ShellLinker configured */
606 if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine",
607 0, KEY_ALL_ACCESS, &hkey ))
609 DWORD type, count = sizeof(buffer);
610 if (RegQueryValueExA( hkey, "ShellLinker", 0, &type, buffer, &count )) buffer[0] = 0;
613 if (!*buffer) return NOERROR;
614 shell_link_app = heap_strdup( buffer );
616 if (!WideCharToMultiByte( CP_ACP, 0, pszFileName, -1, ascii_filename, sizeof(ascii_filename), NULL, NULL))
617 return ERROR_UNKNOWN;
618 GetFullPathNameA( ascii_filename, sizeof(buff2), buff2, NULL );
619 filename = heap_strdup( buff2 );
621 if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTUP, FALSE ))
623 /* ignore startup for now */
624 if (!strncasecmp( filename, buffer, strlen(buffer) )) goto done;
626 if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_DESKTOPDIRECTORY, FALSE ))
628 if (!strncasecmp( filename, buffer, strlen(buffer) ))
630 link_name = filename + strlen(buffer);
635 if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTMENU, FALSE ))
637 if (!strncasecmp( filename, buffer, strlen(buffer) ))
639 link_name = filename + strlen(buffer);
647 /* make link name a Unix name */
648 for (p = link_name; *p; p++) if (*p == '\\') *p = '/';
649 /* strip leading slashes */
650 while (*link_name == '/') link_name++;
651 /* remove extension */
652 if ((p = strrchr( link_name, '.' ))) *p = 0;
654 /* convert app working dir */
655 if (This->sWorkDir) work_dir = get_unix_file_name( This->sWorkDir );
657 /* extract the icon */
658 if (!(icon_name = extract_icon( This->sIcoPath && strlen(This->sIcoPath) ?
659 This->sIcoPath : This->sPath,
662 /* Couldn't extract icon -- defer this menu entry to runonce. */
666 TRACE("Deferring icon creation to reboot.\n");
667 if (RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0,
668 NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hRunOnce, NULL) != ERROR_SUCCESS)
673 buffer = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * 3 + (This->sArgs ? strlen(This->sArgs) : 0) +
674 (This->sDescription ? strlen(This->sDescription) : 0) + 200);
675 sprintf(buffer, "link:%s\xff*%s\xff%d\xff%s\xff%s\xff%s", This->sPath, This->sIcoPath, This->iIcoNdx,
676 This->sArgs ? This->sArgs : "", This->sDescription ? This->sDescription : "",
677 This->sWorkDir ? This->sWorkDir : "");
678 if (RegSetValueExA(hRunOnce, ascii_filename, 0, REG_SZ, buffer, strlen(buffer) + 1) != ERROR_SUCCESS)
680 HeapFree(GetProcessHeap(), 0, buffer);
681 RegCloseKey(hRunOnce);
685 HeapFree(GetProcessHeap(), 0, buffer);
686 RegCloseKey(hRunOnce);
690 TRACE("linker app='%s' link='%s' mode=%s path='%s' args='%s' icon='%s' workdir='%s' descr='%s'\n",
691 shell_link_app, link_name, bDesktop ? "desktop" : "menu", This->sPath,
692 This->sArgs ? This->sArgs : "", icon_name, work_dir ? work_dir : "",
693 This->sDescription ? This->sDescription : "" );
695 if ((pid = fork()) == -1) goto done;
700 argv[pos++] = shell_link_app;
701 argv[pos++] = "--link";
702 argv[pos++] = link_name;
703 argv[pos++] = "--path";
704 argv[pos++] = This->sPath;
705 argv[pos++] = bDesktop ? "--desktop" : "--menu";
706 if (This->sArgs && strlen(This->sArgs))
708 argv[pos++] = "--args";
709 argv[pos++] = This->sArgs;
713 argv[pos++] = "--icon";
714 argv[pos++] = icon_name;
716 if (This->sWorkDir && strlen(This->sWorkDir))
718 argv[pos++] = "--workdir";
719 argv[pos++] = This->sWorkDir;
721 if (This->sDescription && strlen(This->sDescription))
723 argv[pos++] = "--descr";
724 argv[pos++] = This->sDescription;
727 execvp( shell_link_app, argv );
731 while (waitpid( pid, &status, 0 ) == -1)
739 if (status) ret = E_ACCESSDENIED;
742 if (icon_name) unlink( icon_name );
743 HeapFree( GetProcessHeap(), 0, shell_link_app );
744 HeapFree( GetProcessHeap(), 0, filename );
745 HeapFree( GetProcessHeap(), 0, icon_name );
746 HeapFree( GetProcessHeap(), 0, work_dir );
750 static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
752 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
753 FIXME("(%p)->(%s)\n",This,debugstr_w(pszFileName));
756 static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR *ppszFileName)
758 _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
759 FIXME("(%p)\n",This);
763 static ICOM_VTABLE(IPersistFile) pfvt =
765 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
766 IPersistFile_fnQueryInterface,
767 IPersistFile_fnAddRef,
768 IPersistFile_fnRelease,
769 IPersistFile_fnGetClassID,
770 IPersistFile_fnIsDirty,
773 IPersistFile_fnSaveCompleted,
774 IPersistFile_fnGetCurFile
777 /************************************************************************
778 * IPersistStream_QueryInterface
780 static HRESULT WINAPI IPersistStream_fnQueryInterface(
781 IPersistStream* iface,
785 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
787 TRACE("(%p)\n",This);
789 return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvoid);
792 /************************************************************************
793 * IPersistStream_Release
795 static ULONG WINAPI IPersistStream_fnRelease(
796 IPersistStream* iface)
798 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
800 TRACE("(%p)\n",This);
802 return IShellLinkA_Release((IShellLinkA*)This);
805 /************************************************************************
806 * IPersistStream_AddRef
808 static ULONG WINAPI IPersistStream_fnAddRef(
809 IPersistStream* iface)
811 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
813 TRACE("(%p)\n",This);
815 return IShellLinkA_AddRef((IShellLinkA*)This);
818 /************************************************************************
819 * IPersistStream_GetClassID
822 static HRESULT WINAPI IPersistStream_fnGetClassID(
823 IPersistStream* iface,
826 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
828 TRACE("(%p)\n", This);
833 /* memcpy(pClassID, &CLSID_???, sizeof(CLSID_???)); */
838 /************************************************************************
839 * IPersistStream_IsDirty (IPersistStream)
841 static HRESULT WINAPI IPersistStream_fnIsDirty(
842 IPersistStream* iface)
844 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
846 TRACE("(%p)\n", This);
850 /************************************************************************
851 * IPersistStream_Load (IPersistStream)
854 static HRESULT WINAPI IPersistStream_fnLoad(
855 IPersistStream* iface,
856 IStream* pLoadStream)
858 PLINK_HEADER lpLinkHeader = HeapAlloc(GetProcessHeap(), 0, LINK_HEADER_SIZE);
861 char sTemp[MAX_PATH];
863 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
865 TRACE("(%p)(%p)\n", This, pLoadStream);
869 return STG_E_INVALIDPOINTER;
872 IStream_AddRef (pLoadStream);
875 if (SUCCEEDED(IStream_Read(pLoadStream, lpLinkHeader, LINK_HEADER_SIZE, &dwBytesRead)))
877 if ((lpLinkHeader->MagicStr == 0x0000004CL) && IsEqualIID(&lpLinkHeader->MagicGuid, &CLSID_ShellLink))
879 lpLinkHeader = HeapReAlloc(GetProcessHeap(), 0, lpLinkHeader, LINK_HEADER_SIZE+lpLinkHeader->PidlSize);
882 if (SUCCEEDED(IStream_Read(pLoadStream, &(lpLinkHeader->Pidl), lpLinkHeader->PidlSize, &dwBytesRead)))
884 if (pcheck (&lpLinkHeader->Pidl))
886 This->pPidl = ILClone (&lpLinkHeader->Pidl);
888 SHGetPathFromIDListA(&lpLinkHeader->Pidl, sTemp);
889 This->sPath = heap_strdup( sTemp );
891 This->wHotKey = lpLinkHeader->wHotKey;
892 FileTimeToSystemTime (&lpLinkHeader->Time1, &This->time1);
893 FileTimeToSystemTime (&lpLinkHeader->Time2, &This->time2);
894 FileTimeToSystemTime (&lpLinkHeader->Time3, &This->time3);
896 GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time1, NULL, sTemp, 256);
897 TRACE("-- time1: %s\n", sTemp);
898 GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time2, NULL, sTemp, 256);
899 TRACE("-- time1: %s\n", sTemp);
900 GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&This->time3, NULL, sTemp, 256);
901 TRACE("-- time1: %s\n", sTemp);
910 WARN("stream contains no link!\n");
915 IStream_Release (pLoadStream);
919 HeapFree(GetProcessHeap(), 0, lpLinkHeader);
924 /************************************************************************
925 * IPersistStream_Save (IPersistStream)
927 static HRESULT WINAPI IPersistStream_fnSave(
928 IPersistStream* iface,
932 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
934 TRACE("(%p) %p %x\n", This, pOutStream, fClearDirty);
939 /************************************************************************
940 * IPersistStream_GetSizeMax (IPersistStream)
942 static HRESULT WINAPI IPersistStream_fnGetSizeMax(
943 IPersistStream* iface,
944 ULARGE_INTEGER* pcbSize)
946 _ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
948 TRACE("(%p)\n", This);
953 static ICOM_VTABLE(IPersistStream) psvt =
955 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
956 IPersistStream_fnQueryInterface,
957 IPersistStream_fnAddRef,
958 IPersistStream_fnRelease,
959 IPersistStream_fnGetClassID,
960 IPersistStream_fnIsDirty,
961 IPersistStream_fnLoad,
962 IPersistStream_fnSave,
963 IPersistStream_fnGetSizeMax
966 /**************************************************************************
967 * IShellLink_Constructor
969 HRESULT WINAPI IShellLink_Constructor (
970 IUnknown * pUnkOuter,
976 TRACE("unkOut=%p riid=%s\n",pUnkOuter, debugstr_guid(riid));
980 if(pUnkOuter) return CLASS_E_NOAGGREGATION;
981 sl = (IShellLinkImpl *) LocalAlloc(GMEM_ZEROINIT,sizeof(IShellLinkImpl));
982 if (!sl) return E_OUTOFMEMORY;
985 ICOM_VTBL(sl) = &slvt;
986 sl->lpvtblw = &slvtw;
987 sl->lpvtblPersistFile = &pfvt;
988 sl->lpvtblPersistStream = &psvt;
990 TRACE("(%p)->()\n",sl);
992 if (IsEqualIID(riid, &IID_IShellLinkA))
994 else if (IsEqualIID(riid, &IID_IShellLinkW))
995 *ppv = &(sl->lpvtblw);
997 LocalFree((HLOCAL)sl);
998 ERR("E_NOINTERFACE\n");
999 return E_NOINTERFACE;
1005 /**************************************************************************
1006 * IShellLinkA_QueryInterface
1008 static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid, LPVOID *ppvObj)
1010 ICOM_THIS(IShellLinkImpl, iface);
1012 TRACE("(%p)->(\n\tIID:\t%s)\n",This,debugstr_guid(riid));
1016 if(IsEqualIID(riid, &IID_IUnknown) ||
1017 IsEqualIID(riid, &IID_IShellLinkA))
1021 else if(IsEqualIID(riid, &IID_IShellLinkW))
1023 *ppvObj = (IShellLinkW *)&(This->lpvtblw);
1025 else if(IsEqualIID(riid, &IID_IPersistFile))
1027 *ppvObj = (IPersistFile *)&(This->lpvtblPersistFile);
1029 else if(IsEqualIID(riid, &IID_IPersistStream))
1031 *ppvObj = (IPersistStream *)&(This->lpvtblPersistStream);
1036 IUnknown_AddRef((IUnknown*)(*ppvObj));
1037 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1040 TRACE("-- Interface: E_NOINTERFACE\n");
1041 return E_NOINTERFACE;
1043 /******************************************************************************
1044 * IShellLinkA_AddRef
1046 static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface)
1048 ICOM_THIS(IShellLinkImpl, iface);
1050 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1052 return ++(This->ref);
1054 /******************************************************************************
1055 * IShellLinkA_Release
1057 static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface)
1059 ICOM_THIS(IShellLinkImpl, iface);
1061 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1064 { TRACE("-- destroying IShellLink(%p)\n",This);
1067 HeapFree(GetProcessHeap(), 0, This->sIcoPath);
1070 HeapFree(GetProcessHeap(), 0, This->sArgs);
1073 HeapFree(GetProcessHeap(), 0, This->sWorkDir);
1075 if (This->sDescription)
1076 HeapFree(GetProcessHeap(), 0, This->sDescription);
1079 HeapFree(GetProcessHeap(),0,This->sPath);
1082 SHFree(This->pPidl);
1084 if (This->lpFileStream)
1085 IStream_Release(This->lpFileStream);
1089 LocalFree((HANDLE)This);
1095 static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA * iface, LPSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
1097 ICOM_THIS(IShellLinkImpl, iface);
1099 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n",This, pszFile, cchMaxPath, pfd, fFlags, debugstr_a(This->sPath));
1102 lstrcpynA(pszFile,This->sPath, cchMaxPath);
1108 static HRESULT WINAPI IShellLinkA_fnGetIDList(IShellLinkA * iface, LPITEMIDLIST * ppidl)
1110 ICOM_THIS(IShellLinkImpl, iface);
1112 TRACE("(%p)->(ppidl=%p)\n",This, ppidl);
1114 *ppidl = ILClone(This->pPidl);
1117 static HRESULT WINAPI IShellLinkA_fnSetIDList(IShellLinkA * iface, LPCITEMIDLIST pidl)
1119 ICOM_THIS(IShellLinkImpl, iface);
1121 TRACE("(%p)->(pidl=%p)\n",This, pidl);
1124 SHFree(This->pPidl);
1125 This->pPidl = ILClone (pidl);
1128 static HRESULT WINAPI IShellLinkA_fnGetDescription(IShellLinkA * iface, LPSTR pszName,INT cchMaxName)
1130 ICOM_THIS(IShellLinkImpl, iface);
1132 FIXME("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
1133 lstrcpynA(pszName,"Description, FIXME",cchMaxName);
1136 static HRESULT WINAPI IShellLinkA_fnSetDescription(IShellLinkA * iface, LPCSTR pszName)
1138 ICOM_THIS(IShellLinkImpl, iface);
1140 TRACE("(%p)->(pName=%s)\n", This, pszName);
1142 if (This->sDescription)
1143 HeapFree(GetProcessHeap(), 0, This->sDescription);
1144 if (!(This->sDescription = heap_strdup(pszName)))
1145 return E_OUTOFMEMORY;
1149 static HRESULT WINAPI IShellLinkA_fnGetWorkingDirectory(IShellLinkA * iface, LPSTR pszDir,INT cchMaxPath)
1151 ICOM_THIS(IShellLinkImpl, iface);
1153 TRACE("(%p)->(%p len=%u)\n", This, pszDir, cchMaxPath);
1155 lstrcpynA( pszDir, This->sWorkDir ? This->sWorkDir : "", cchMaxPath );
1159 static HRESULT WINAPI IShellLinkA_fnSetWorkingDirectory(IShellLinkA * iface, LPCSTR pszDir)
1161 ICOM_THIS(IShellLinkImpl, iface);
1163 TRACE("(%p)->(dir=%s)\n",This, pszDir);
1166 HeapFree(GetProcessHeap(), 0, This->sWorkDir);
1167 if (!(This->sWorkDir = heap_strdup(pszDir)))
1168 return E_OUTOFMEMORY;
1172 static HRESULT WINAPI IShellLinkA_fnGetArguments(IShellLinkA * iface, LPSTR pszArgs,INT cchMaxPath)
1174 ICOM_THIS(IShellLinkImpl, iface);
1176 TRACE("(%p)->(%p len=%u)\n", This, pszArgs, cchMaxPath);
1178 lstrcpynA( pszArgs, This->sArgs ? This->sArgs : "", cchMaxPath );
1182 static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA * iface, LPCSTR pszArgs)
1184 ICOM_THIS(IShellLinkImpl, iface);
1186 TRACE("(%p)->(args=%s)\n",This, pszArgs);
1189 HeapFree(GetProcessHeap(), 0, This->sArgs);
1190 if (!(This->sArgs = heap_strdup(pszArgs)))
1191 return E_OUTOFMEMORY;
1195 static HRESULT WINAPI IShellLinkA_fnGetHotkey(IShellLinkA * iface, WORD *pwHotkey)
1197 ICOM_THIS(IShellLinkImpl, iface);
1199 TRACE("(%p)->(%p)(0x%08x)\n",This, pwHotkey, This->wHotKey);
1201 *pwHotkey = This->wHotKey;
1205 static HRESULT WINAPI IShellLinkA_fnSetHotkey(IShellLinkA * iface, WORD wHotkey)
1207 ICOM_THIS(IShellLinkImpl, iface);
1209 TRACE("(%p)->(hotkey=%x)\n",This, wHotkey);
1211 This->wHotKey = wHotkey;
1215 static HRESULT WINAPI IShellLinkA_fnGetShowCmd(IShellLinkA * iface, INT *piShowCmd)
1217 ICOM_THIS(IShellLinkImpl, iface);
1219 FIXME("(%p)->(%p)\n",This, piShowCmd);
1223 static HRESULT WINAPI IShellLinkA_fnSetShowCmd(IShellLinkA * iface, INT iShowCmd)
1225 ICOM_THIS(IShellLinkImpl, iface);
1227 FIXME("(%p)->(showcmd=%x)\n",This, iShowCmd);
1230 static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
1232 ICOM_THIS(IShellLinkImpl, iface);
1234 TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon);
1236 lstrcpynA( pszIconPath, This->sIcoPath ? This->sIcoPath : "", cchIconPath );
1237 *piIcon = This->iIcoNdx;
1241 static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath,INT iIcon)
1243 ICOM_THIS(IShellLinkImpl, iface);
1245 TRACE("(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
1248 HeapFree(GetProcessHeap(), 0, This->sIcoPath);
1249 if (!(This->sIcoPath = heap_strdup(pszIconPath)))
1250 return E_OUTOFMEMORY;
1251 This->iIcoNdx = iIcon;
1255 static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR pszPathRel, DWORD dwReserved)
1257 ICOM_THIS(IShellLinkImpl, iface);
1259 FIXME("(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved);
1262 static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWORD fFlags)
1264 ICOM_THIS(IShellLinkImpl, iface);
1266 FIXME("(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
1269 static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile)
1271 ICOM_THIS(IShellLinkImpl, iface);
1273 TRACE("(%p)->(path=%s)\n",This, pszFile);
1276 HeapFree(GetProcessHeap(), 0, This->sPath);
1277 if (!(This->sPath = heap_strdup(pszFile)))
1278 return E_OUTOFMEMORY;
1283 /**************************************************************************
1284 * IShellLink Implementation
1287 static ICOM_VTABLE(IShellLinkA) slvt =
1289 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1290 IShellLinkA_fnQueryInterface,
1291 IShellLinkA_fnAddRef,
1292 IShellLinkA_fnRelease,
1293 IShellLinkA_fnGetPath,
1294 IShellLinkA_fnGetIDList,
1295 IShellLinkA_fnSetIDList,
1296 IShellLinkA_fnGetDescription,
1297 IShellLinkA_fnSetDescription,
1298 IShellLinkA_fnGetWorkingDirectory,
1299 IShellLinkA_fnSetWorkingDirectory,
1300 IShellLinkA_fnGetArguments,
1301 IShellLinkA_fnSetArguments,
1302 IShellLinkA_fnGetHotkey,
1303 IShellLinkA_fnSetHotkey,
1304 IShellLinkA_fnGetShowCmd,
1305 IShellLinkA_fnSetShowCmd,
1306 IShellLinkA_fnGetIconLocation,
1307 IShellLinkA_fnSetIconLocation,
1308 IShellLinkA_fnSetRelativePath,
1309 IShellLinkA_fnResolve,
1310 IShellLinkA_fnSetPath
1314 /**************************************************************************
1315 * IShellLinkW_fnQueryInterface
1317 static HRESULT WINAPI IShellLinkW_fnQueryInterface(
1318 IShellLinkW * iface, REFIID riid, LPVOID *ppvObj)
1320 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1322 return IShellLinkA_QueryInterface((IShellLinkA*)This, riid, ppvObj);
1325 /******************************************************************************
1326 * IShellLinkW_fnAddRef
1328 static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface)
1330 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1332 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1334 return IShellLinkA_AddRef((IShellLinkA*)This);
1336 /******************************************************************************
1337 * IShellLinkW_fnRelease
1340 static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
1342 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1344 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1346 return IShellLinkA_Release((IShellLinkA*)This);
1349 static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
1351 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1353 FIXME("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
1354 MultiByteToWideChar( CP_ACP, 0, "c:\\foo.bar", -1, pszFile, cchMaxPath );
1358 static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl)
1360 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1362 FIXME("(%p)->(ppidl=%p)\n",This, ppidl);
1363 *ppidl = _ILCreateDesktop();
1367 static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl)
1369 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1371 FIXME("(%p)->(pidl=%p)\n",This, pidl);
1375 static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR pszName,INT cchMaxName)
1377 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1379 FIXME("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
1380 MultiByteToWideChar( CP_ACP, 0, "Description, FIXME", -1, pszName, cchMaxName );
1384 static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR pszName)
1386 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1388 TRACE("(%p)->(desc=%s)\n",This, debugstr_w(pszName));
1390 if (This->sDescription)
1391 HeapFree(GetProcessHeap(), 0, This->sDescription);
1392 if (!(This->sDescription = HEAP_strdupWtoA(GetProcessHeap(), 0, pszName)))
1393 return E_OUTOFMEMORY;
1398 static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPWSTR pszDir,INT cchMaxPath)
1400 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1402 TRACE("(%p)->(%p len %u)\n", This, pszDir, cchMaxPath);
1404 MultiByteToWideChar( CP_ACP, 0, This->sWorkDir ? This->sWorkDir : "", -1, pszDir, cchMaxPath );
1409 static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPCWSTR pszDir)
1411 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1413 TRACE("(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
1416 HeapFree(GetProcessHeap(), 0, This->sWorkDir);
1417 if (!(This->sWorkDir = HEAP_strdupWtoA(GetProcessHeap(), 0, pszDir)))
1418 return E_OUTOFMEMORY;
1423 static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR pszArgs,INT cchMaxPath)
1425 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1427 TRACE("(%p)->(%p len=%u)\n", This, pszArgs, cchMaxPath);
1429 MultiByteToWideChar( CP_ACP, 0, This->sArgs ? This->sArgs : "", -1, pszArgs, cchMaxPath );
1434 static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR pszArgs)
1436 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1438 TRACE("(%p)->(args=%s)\n",This, debugstr_w(pszArgs));
1441 HeapFree(GetProcessHeap(), 0, This->sArgs);
1442 if (!(This->sArgs = HEAP_strdupWtoA(GetProcessHeap(), 0, pszArgs)))
1443 return E_OUTOFMEMORY;
1448 static HRESULT WINAPI IShellLinkW_fnGetHotkey(IShellLinkW * iface, WORD *pwHotkey)
1450 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1452 FIXME("(%p)->(%p)\n",This, pwHotkey);
1457 static HRESULT WINAPI IShellLinkW_fnSetHotkey(IShellLinkW * iface, WORD wHotkey)
1459 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1461 FIXME("(%p)->(hotkey=%x)\n",This, wHotkey);
1465 static HRESULT WINAPI IShellLinkW_fnGetShowCmd(IShellLinkW * iface, INT *piShowCmd)
1467 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1469 FIXME("(%p)->(%p)\n",This, piShowCmd);
1474 static HRESULT WINAPI IShellLinkW_fnSetShowCmd(IShellLinkW * iface, INT iShowCmd)
1476 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1478 FIXME("(%p)->(showcmd=%x)\n",This, iShowCmd);
1482 static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon)
1484 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1486 TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon);
1488 MultiByteToWideChar( CP_ACP, 0, This->sIcoPath ? This->sIcoPath : "", -1, pszIconPath, cchIconPath );
1489 *piIcon = This->iIcoNdx;
1494 static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon)
1496 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1498 TRACE("(%p)->(path=%s iicon=%u)\n",This, debugstr_w(pszIconPath), iIcon);
1501 HeapFree(GetProcessHeap(), 0, This->sIcoPath);
1502 if (!(This->sIcoPath = HEAP_strdupWtoA(GetProcessHeap(), 0, pszIconPath)))
1503 return E_OUTOFMEMORY;
1504 This->iIcoNdx = iIcon;
1509 static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR pszPathRel, DWORD dwReserved)
1511 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1513 FIXME("(%p)->(path=%s %lx)\n",This, debugstr_w(pszPathRel), dwReserved);
1517 static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWORD fFlags)
1519 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1521 FIXME("(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
1525 static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile)
1527 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
1529 TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile));
1532 HeapFree(GetProcessHeap(), 0, This->sPath);
1533 if (!(This->sPath = HEAP_strdupWtoA(GetProcessHeap(), 0, pszFile)))
1534 return E_OUTOFMEMORY;
1539 /**************************************************************************
1540 * IShellLinkW Implementation
1543 static ICOM_VTABLE(IShellLinkW) slvtw =
1545 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1546 IShellLinkW_fnQueryInterface,
1547 IShellLinkW_fnAddRef,
1548 IShellLinkW_fnRelease,
1549 IShellLinkW_fnGetPath,
1550 IShellLinkW_fnGetIDList,
1551 IShellLinkW_fnSetIDList,
1552 IShellLinkW_fnGetDescription,
1553 IShellLinkW_fnSetDescription,
1554 IShellLinkW_fnGetWorkingDirectory,
1555 IShellLinkW_fnSetWorkingDirectory,
1556 IShellLinkW_fnGetArguments,
1557 IShellLinkW_fnSetArguments,
1558 IShellLinkW_fnGetHotkey,
1559 IShellLinkW_fnSetHotkey,
1560 IShellLinkW_fnGetShowCmd,
1561 IShellLinkW_fnSetShowCmd,
1562 IShellLinkW_fnGetIconLocation,
1563 IShellLinkW_fnSetIconLocation,
1564 IShellLinkW_fnSetRelativePath,
1565 IShellLinkW_fnResolve,
1566 IShellLinkW_fnSetPath