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"
37 #include "undocshell.h"
38 #include "bitmaps/wine.xpm"
42 #include "shell32_main.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
47 /* link file formats */
51 /* flag1: lnk elements: simple link has 0x0B */
59 #define MAXIMIZED 0x03
60 #define MINIMIZED 0x07
62 typedef struct _LINK_HEADER
63 { DWORD MagicStr
; /* 0x00 'L','\0','\0','\0' */
64 GUID MagicGuid
; /* 0x04 is CLSID_ShellLink */
65 DWORD Flag1
; /* 0x14 describes elements following */
66 DWORD Flag2
; /* 0x18 */
67 FILETIME Time1
; /* 0x1c */
68 FILETIME Time2
; /* 0x24 */
69 FILETIME Time3
; /* 0x2c */
70 DWORD Unknown1
; /* 0x34 */
71 DWORD Unknown2
; /* 0x38 icon number */
72 DWORD fStartup
; /* 0x3c startup type */
73 DWORD wHotKey
; /* 0x40 hotkey */
74 DWORD Unknown5
; /* 0x44 */
75 DWORD Unknown6
; /* 0x48 */
76 USHORT PidlSize
; /* 0x4c */
77 ITEMIDLIST Pidl
; /* 0x4e */
78 } LINK_HEADER
, * PLINK_HEADER
;
80 #define LINK_HEADER_SIZE (sizeof(LINK_HEADER)-sizeof(ITEMIDLIST))
99 GRPICONDIRENTRY idEntries
[1];
130 static ICOM_VTABLE(IShellLinkA
) slvt
;
131 static ICOM_VTABLE(IShellLinkW
) slvtw
;
132 static ICOM_VTABLE(IPersistFile
) pfvt
;
133 static ICOM_VTABLE(IPersistStream
) psvt
;
135 /* IShellLink Implementation */
139 ICOM_VFIELD(IShellLinkA
);
142 ICOM_VTABLE(IShellLinkW
)* lpvtblw
;
143 ICOM_VTABLE(IPersistFile
)* lpvtblPersistFile
;
144 ICOM_VTABLE(IPersistStream
)* lpvtblPersistStream
;
146 /* internal stream of the IPersistFile interface */
147 IStream
* lpFileStream
;
149 /* data structures according to the informations in the lnk */
164 #define _IShellLinkW_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblw)))
165 #define _ICOM_THIS_From_IShellLinkW(class, name) class* This = (class*)(((char*)name)-_IShellLinkW_Offset);
167 #define _IPersistFile_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistFile)))
168 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
170 #define _IPersistStream_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistStream)))
171 #define _ICOM_THIS_From_IPersistStream(class, name) class* This = (class*)(((char*)name)-_IPersistStream_Offset);
172 #define _IPersistStream_From_ICOM_THIS(class, name) class* StreamThis = (class*)(((char*)name)+_IPersistStream_Offset);
175 /* strdup on the process heap */
176 inline static LPSTR
heap_strdup( LPCSTR str
)
178 INT len
= strlen(str
) + 1;
179 LPSTR p
= HeapAlloc( GetProcessHeap(), 0, len
);
180 if (p
) memcpy( p
, str
, len
);
185 /**************************************************************************
186 * IPersistFile_QueryInterface
188 static HRESULT WINAPI
IPersistFile_fnQueryInterface(
193 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
195 TRACE("(%p)\n",This
);
197 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObj
);
200 /******************************************************************************
201 * IPersistFile_AddRef
203 static ULONG WINAPI
IPersistFile_fnAddRef(IPersistFile
* iface
)
205 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
207 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
209 return IShellLinkA_AddRef((IShellLinkA
*)This
);
211 /******************************************************************************
212 * IPersistFile_Release
214 static ULONG WINAPI
IPersistFile_fnRelease(IPersistFile
* iface
)
216 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
218 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
220 return IShellLinkA_Release((IShellLinkA
*)This
);
223 static HRESULT WINAPI
IPersistFile_fnGetClassID(IPersistFile
* iface
, CLSID
*pClassID
)
225 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
226 FIXME("(%p)\n",This
);
229 static HRESULT WINAPI
IPersistFile_fnIsDirty(IPersistFile
* iface
)
231 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
232 FIXME("(%p)\n",This
);
235 static HRESULT WINAPI
IPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
237 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
238 _IPersistStream_From_ICOM_THIS(IPersistStream
, This
)
240 LPSTR sFile
= HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName
);
241 HRESULT hRet
= E_FAIL
;
243 TRACE("(%p, %s)\n",This
, sFile
);
246 if (This
->lpFileStream
)
247 IStream_Release(This
->lpFileStream
);
249 if SUCCEEDED(CreateStreamOnFile(sFile
, &(This
->lpFileStream
)))
251 if SUCCEEDED (IPersistStream_Load(StreamThis
, This
->lpFileStream
))
261 /* Icon extraction routines
263 * FIXME: should use PrivateExtractIcons and friends
264 * FIXME: should not use stdio
267 static BOOL
SaveIconResAsXPM(const BITMAPINFO
*pIcon
, const char *szXPMFileName
)
277 BOOL aColorUsed
[256] = {0};
281 if (!((pIcon
->bmiHeader
.biBitCount
== 4) || (pIcon
->bmiHeader
.biBitCount
== 8)))
284 if (!(fXPMFile
= fopen(szXPMFileName
, "w")))
287 nHeight
= pIcon
->bmiHeader
.biHeight
/ 2;
288 nXORWidthBytes
= 4 * ((pIcon
->bmiHeader
.biWidth
* pIcon
->bmiHeader
.biBitCount
/ 32)
289 + ((pIcon
->bmiHeader
.biWidth
* pIcon
->bmiHeader
.biBitCount
% 32) > 0));
290 nANDWidthBytes
= 4 * ((pIcon
->bmiHeader
.biWidth
/ 32)
291 + ((pIcon
->bmiHeader
.biWidth
% 32) > 0));
292 b8BitColors
= pIcon
->bmiHeader
.biBitCount
== 8;
293 nColors
= pIcon
->bmiHeader
.biClrUsed
? pIcon
->bmiHeader
.biClrUsed
294 : 1 << pIcon
->bmiHeader
.biBitCount
;
295 pXOR
= (BYTE
*) pIcon
+ sizeof (BITMAPINFOHEADER
) + (nColors
* sizeof (RGBQUAD
));
296 pAND
= pXOR
+ nHeight
* nXORWidthBytes
;
298 #define MASK(x,y) (pAND[(x) / 8 + (nHeight - (y) - 1) * nANDWidthBytes] & (1 << (7 - (x) % 8)))
299 #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)
301 for (i
= 0; i
< nHeight
; i
++)
302 for (j
= 0; j
< pIcon
->bmiHeader
.biWidth
; j
++)
303 if (!aColorUsed
[COLOR(j
,i
)] && !MASK(j
,i
))
305 aColorUsed
[COLOR(j
,i
)] = TRUE
;
309 if (fprintf(fXPMFile
, "/* XPM */\nstatic char *icon[] = {\n") <= 0)
311 if (fprintf(fXPMFile
, "\"%d %d %d %d\",\n",
312 (int) pIcon
->bmiHeader
.biWidth
, nHeight
, nColorsUsed
+ 1, 2) <=0)
315 for (i
= 0; i
< nColors
; i
++)
317 if (fprintf(fXPMFile
, "\"%.2X c #%.2X%.2X%.2X\",\n", i
, pIcon
->bmiColors
[i
].rgbRed
,
318 pIcon
->bmiColors
[i
].rgbGreen
, pIcon
->bmiColors
[i
].rgbBlue
) <= 0)
320 if (fprintf(fXPMFile
, "\" c None\"") <= 0)
323 for (i
= 0; i
< nHeight
; i
++)
325 if (fprintf(fXPMFile
, ",\n\"") <= 0)
327 for (j
= 0; j
< pIcon
->bmiHeader
.biWidth
; j
++)
331 if (fprintf(fXPMFile
, " ") <= 0)
335 if (fprintf(fXPMFile
, "%.2X", COLOR(j
,i
)) <= 0)
338 if (fprintf(fXPMFile
, "\"") <= 0)
341 if (fprintf(fXPMFile
, "};\n") <= 0)
352 unlink( szXPMFileName
);
356 static BOOL CALLBACK
EnumResNameProc(HANDLE hModule
, const char *lpszType
, char *lpszName
, LONG lParam
)
358 ENUMRESSTRUCT
*sEnumRes
= (ENUMRESSTRUCT
*) lParam
;
360 if (!sEnumRes
->nIndex
--)
362 *sEnumRes
->pResInfo
= FindResourceA(hModule
, lpszName
, RT_GROUP_ICONA
);
369 static int ExtractFromEXEDLL(const char *szFileName
, int nIndex
, const char *szXPMFileName
)
375 GRPICONDIR
*pIconDir
;
377 ENUMRESSTRUCT sEnumRes
;
382 if (!(hModule
= LoadLibraryExA(szFileName
, 0, LOAD_LIBRARY_AS_DATAFILE
)))
384 TRACE("LoadLibraryExA (%s) failed, error %ld\n", szFileName
, GetLastError());
390 hResInfo
= FindResourceA(hModule
, MAKEINTRESOURCEA(-nIndex
), RT_GROUP_ICONA
);
391 TRACE("FindResourceA (%s) called, return 0x%x, error %ld\n", szFileName
, hResInfo
, GetLastError());
395 sEnumRes
.pResInfo
= &hResInfo
;
396 sEnumRes
.nIndex
= nIndex
;
397 if (EnumResourceNamesA(hModule
, RT_GROUP_ICONA
, &EnumResNameProc
, (LONG
) &sEnumRes
))
399 TRACE("EnumResourceNamesA failed, error %ld\n", GetLastError());
406 TRACE("ExtractFromEXEDLL failed, error %ld\n", GetLastError());
410 if (!(hResData
= LoadResource(hModule
, hResInfo
)))
412 TRACE("LoadResource failed, error %ld\n", GetLastError());
415 if (!(pIconDir
= LockResource(hResData
)))
417 TRACE("LockResource failed, error %ld\n", GetLastError());
421 for (i
= 0; i
< pIconDir
->idCount
; i
++)
422 if ((pIconDir
->idEntries
[i
].wBitCount
>= nMaxBits
) && (pIconDir
->idEntries
[i
].wBitCount
<= 8))
424 if (pIconDir
->idEntries
[i
].wBitCount
> nMaxBits
)
426 nMaxBits
= pIconDir
->idEntries
[i
].wBitCount
;
429 if ((pIconDir
->idEntries
[i
].bHeight
* pIconDir
->idEntries
[i
].bWidth
) > nMax
)
431 lpName
= MAKEINTRESOURCEA(pIconDir
->idEntries
[i
].nID
);
432 nMax
= pIconDir
->idEntries
[i
].bHeight
* pIconDir
->idEntries
[i
].bWidth
;
436 FreeResource(hResData
);
438 if (!(hResInfo
= FindResourceA(hModule
, lpName
, RT_ICONA
)))
440 TRACE("Second FindResourceA failed, error %ld\n", GetLastError());
443 if (!(hResData
= LoadResource(hModule
, hResInfo
)))
445 TRACE("Second LoadResource failed, error %ld\n", GetLastError());
448 if (!(pIcon
= LockResource(hResData
)))
450 TRACE("Second LockResource failed, error %ld\n", GetLastError());
454 if(!SaveIconResAsXPM(pIcon
, szXPMFileName
))
456 TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
460 FreeResource(hResData
);
461 FreeLibrary(hModule
);
466 FreeResource(hResData
);
468 FreeLibrary(hModule
);
473 static int ExtractFromICO(const char *szFileName
, const char *szXPMFileName
)
477 ICONDIRENTRY
*pIconDirEntry
;
483 if (!(fICOFile
= fopen(szFileName
, "r")))
486 if (fread(&iconDir
, sizeof (ICONDIR
), 1, fICOFile
) != 1)
488 if ((iconDir
.idReserved
!= 0) || (iconDir
.idType
!= 1))
491 if ((pIconDirEntry
= malloc(iconDir
.idCount
* sizeof (ICONDIRENTRY
))) == NULL
)
493 if (fread(pIconDirEntry
, sizeof (ICONDIRENTRY
), iconDir
.idCount
, fICOFile
) != iconDir
.idCount
)
496 for (i
= 0; i
< iconDir
.idCount
; i
++)
497 if ((pIconDirEntry
[i
].bHeight
* pIconDirEntry
[i
].bWidth
) > nMax
)
500 nMax
= pIconDirEntry
[i
].bHeight
* pIconDirEntry
[i
].bWidth
;
502 if ((pIcon
= malloc(pIconDirEntry
[nIndex
].dwBytesInRes
)) == NULL
)
504 if (fseek(fICOFile
, pIconDirEntry
[nIndex
].dwImageOffset
, SEEK_SET
))
506 if (fread(pIcon
, pIconDirEntry
[nIndex
].dwBytesInRes
, 1, fICOFile
) != 1)
509 if(!SaveIconResAsXPM(pIcon
, szXPMFileName
))
528 /* get the Unix file name for a given path, allocating the string */
529 inline static char *get_unix_file_name( const char *dos
)
531 char buffer
[MAX_PATH
];
533 if (!wine_get_unix_file_name( dos
, buffer
, sizeof(buffer
) )) return NULL
;
534 return heap_strdup( buffer
);
537 static BOOL
create_default_icon( const char *filename
)
542 if (!(fXPM
= fopen(filename
, "w"))) return FALSE
;
543 fprintf(fXPM
, "/* XPM */\nstatic char * icon[] = {");
544 for (i
= 0; i
< sizeof(wine_xpm
)/sizeof(wine_xpm
[0]); i
++)
545 fprintf( fXPM
, "\n\"%s\",", wine_xpm
[i
]);
546 fprintf( fXPM
, "};\n" );
551 /* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */
552 static char *extract_icon( const char *path
, int index
)
555 char *filename
= heap_strdup( tmpnam(NULL
) );
557 /* If icon path begins with a '*' then this is a deferred call */
563 if (ExtractFromEXEDLL( path
, index
, filename
)) return filename
;
564 if (ExtractFromICO( path
, filename
)) return filename
;
566 if (create_default_icon( filename
)) return filename
;
567 HeapFree( GetProcessHeap(), 0, filename
);
572 static HRESULT WINAPI
IPersistFile_fnSave(IPersistFile
* iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
574 HRESULT ret
= NOERROR
;
576 char buffer
[MAX_PATH
], buff2
[MAX_PATH
], ascii_filename
[MAX_PATH
];
577 char *filename
, *link_name
, *p
;
578 char *shell_link_app
= NULL
;
579 char *icon_name
= NULL
;
580 char *work_dir
= NULL
;
584 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
586 TRACE("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
588 if (!pszFileName
|| !This
->sPath
)
589 return ERROR_UNKNOWN
;
591 /* check for .exe extension */
592 if (!(p
= strrchr( This
->sPath
, '.' ))) return NOERROR
;
593 if (strchr( p
, '\\' ) || strchr( p
, '/' )) return NOERROR
;
594 if (strcasecmp( p
, ".exe" )) return NOERROR
;
596 /* check if ShellLinker configured */
598 if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Wine\\Config\\Wine",
599 0, KEY_ALL_ACCESS
, &hkey
))
601 DWORD type
, count
= sizeof(buffer
);
602 if (RegQueryValueExA( hkey
, "ShellLinker", 0, &type
, buffer
, &count
)) buffer
[0] = 0;
605 if (!*buffer
) return NOERROR
;
606 shell_link_app
= heap_strdup( buffer
);
608 if (!WideCharToMultiByte( CP_ACP
, 0, pszFileName
, -1, ascii_filename
, sizeof(ascii_filename
), NULL
, NULL
))
609 return ERROR_UNKNOWN
;
610 GetFullPathNameA( ascii_filename
, sizeof(buff2
), buff2
, NULL
);
611 filename
= heap_strdup( buff2
);
613 if (SHGetSpecialFolderPathA( 0, buffer
, CSIDL_STARTUP
, FALSE
))
615 /* ignore startup for now */
616 if (!strncasecmp( filename
, buffer
, strlen(buffer
) )) goto done
;
618 if (SHGetSpecialFolderPathA( 0, buffer
, CSIDL_DESKTOPDIRECTORY
, FALSE
))
620 if (!strncasecmp( filename
, buffer
, strlen(buffer
) ))
622 link_name
= filename
+ strlen(buffer
);
627 if (SHGetSpecialFolderPathA( 0, buffer
, CSIDL_STARTMENU
, FALSE
))
629 if (!strncasecmp( filename
, buffer
, strlen(buffer
) ))
631 link_name
= filename
+ strlen(buffer
);
639 /* make link name a Unix name */
640 for (p
= link_name
; *p
; p
++) if (*p
== '\\') *p
= '/';
641 /* strip leading slashes */
642 while (*link_name
== '/') link_name
++;
643 /* remove extension */
644 if ((p
= strrchr( link_name
, '.' ))) *p
= 0;
646 /* convert app working dir */
647 if (This
->sWorkDir
) work_dir
= get_unix_file_name( This
->sWorkDir
);
649 /* extract the icon */
650 if (!(icon_name
= extract_icon( This
->sIcoPath
&& strlen(This
->sIcoPath
) ?
651 This
->sIcoPath
: This
->sPath
,
654 /* Couldn't extract icon -- defer this menu entry to runonce. */
658 TRACE("Deferring icon creation to reboot.\n");
659 if (RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0,
660 NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hRunOnce
, NULL
) != ERROR_SUCCESS
)
665 buffer
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
* 3 + (This
->sArgs
? strlen(This
->sArgs
) : 0) +
666 (This
->sDescription
? strlen(This
->sDescription
) : 0) + 200);
667 sprintf(buffer
, "link:%s\xff*%s\xff%d\xff%s\xff%s\xff%s", This
->sPath
, This
->sIcoPath
, This
->iIcoNdx
,
668 This
->sArgs
? This
->sArgs
: "", This
->sDescription
? This
->sDescription
: "",
669 This
->sWorkDir
? This
->sWorkDir
: "");
670 if (RegSetValueExA(hRunOnce
, ascii_filename
, 0, REG_SZ
, buffer
, strlen(buffer
) + 1) != ERROR_SUCCESS
)
672 HeapFree(GetProcessHeap(), 0, buffer
);
673 RegCloseKey(hRunOnce
);
677 HeapFree(GetProcessHeap(), 0, buffer
);
678 RegCloseKey(hRunOnce
);
682 TRACE("linker app='%s' link='%s' mode=%s path='%s' args='%s' icon='%s' workdir='%s' descr='%s'\n",
683 shell_link_app
, link_name
, bDesktop
? "desktop" : "menu", This
->sPath
,
684 This
->sArgs
? This
->sArgs
: "", icon_name
, work_dir
? work_dir
: "",
685 This
->sDescription
? This
->sDescription
: "" );
687 if ((pid
= fork()) == -1) goto done
;
692 argv
[pos
++] = shell_link_app
;
693 argv
[pos
++] = "--link";
694 argv
[pos
++] = link_name
;
695 argv
[pos
++] = "--path";
696 argv
[pos
++] = This
->sPath
;
697 argv
[pos
++] = bDesktop
? "--desktop" : "--menu";
698 if (This
->sArgs
&& strlen(This
->sArgs
))
700 argv
[pos
++] = "--args";
701 argv
[pos
++] = This
->sArgs
;
705 argv
[pos
++] = "--icon";
706 argv
[pos
++] = icon_name
;
708 if (This
->sWorkDir
&& strlen(This
->sWorkDir
))
710 argv
[pos
++] = "--workdir";
711 argv
[pos
++] = This
->sWorkDir
;
713 if (This
->sDescription
&& strlen(This
->sDescription
))
715 argv
[pos
++] = "--descr";
716 argv
[pos
++] = This
->sDescription
;
719 execvp( shell_link_app
, argv
);
723 while (waitpid( pid
, &status
, 0 ) == -1)
731 if (status
) ret
= E_ACCESSDENIED
;
734 if (icon_name
) unlink( icon_name
);
735 HeapFree( GetProcessHeap(), 0, shell_link_app
);
736 HeapFree( GetProcessHeap(), 0, filename
);
737 HeapFree( GetProcessHeap(), 0, icon_name
);
738 HeapFree( GetProcessHeap(), 0, work_dir
);
742 static HRESULT WINAPI
IPersistFile_fnSaveCompleted(IPersistFile
* iface
, LPCOLESTR pszFileName
)
744 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
745 FIXME("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
748 static HRESULT WINAPI
IPersistFile_fnGetCurFile(IPersistFile
* iface
, LPOLESTR
*ppszFileName
)
750 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
751 FIXME("(%p)\n",This
);
755 static ICOM_VTABLE(IPersistFile
) pfvt
=
757 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
758 IPersistFile_fnQueryInterface
,
759 IPersistFile_fnAddRef
,
760 IPersistFile_fnRelease
,
761 IPersistFile_fnGetClassID
,
762 IPersistFile_fnIsDirty
,
765 IPersistFile_fnSaveCompleted
,
766 IPersistFile_fnGetCurFile
769 /************************************************************************
770 * IPersistStream_QueryInterface
772 static HRESULT WINAPI
IPersistStream_fnQueryInterface(
773 IPersistStream
* iface
,
777 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
779 TRACE("(%p)\n",This
);
781 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvoid
);
784 /************************************************************************
785 * IPersistStream_Release
787 static ULONG WINAPI
IPersistStream_fnRelease(
788 IPersistStream
* iface
)
790 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
792 TRACE("(%p)\n",This
);
794 return IShellLinkA_Release((IShellLinkA
*)This
);
797 /************************************************************************
798 * IPersistStream_AddRef
800 static ULONG WINAPI
IPersistStream_fnAddRef(
801 IPersistStream
* iface
)
803 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
805 TRACE("(%p)\n",This
);
807 return IShellLinkA_AddRef((IShellLinkA
*)This
);
810 /************************************************************************
811 * IPersistStream_GetClassID
814 static HRESULT WINAPI
IPersistStream_fnGetClassID(
815 IPersistStream
* iface
,
818 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
820 TRACE("(%p)\n", This
);
825 /* memcpy(pClassID, &CLSID_???, sizeof(CLSID_???)); */
830 /************************************************************************
831 * IPersistStream_IsDirty (IPersistStream)
833 static HRESULT WINAPI
IPersistStream_fnIsDirty(
834 IPersistStream
* iface
)
836 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
838 TRACE("(%p)\n", This
);
842 /************************************************************************
843 * IPersistStream_Load (IPersistStream)
846 static HRESULT WINAPI
IPersistStream_fnLoad(
847 IPersistStream
* iface
,
848 IStream
* pLoadStream
)
850 PLINK_HEADER lpLinkHeader
= HeapAlloc(GetProcessHeap(), 0, LINK_HEADER_SIZE
);
853 char sTemp
[MAX_PATH
];
855 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
857 TRACE("(%p)(%p)\n", This
, pLoadStream
);
861 return STG_E_INVALIDPOINTER
;
864 IStream_AddRef (pLoadStream
);
867 if (SUCCEEDED(IStream_Read(pLoadStream
, lpLinkHeader
, LINK_HEADER_SIZE
, &dwBytesRead
)))
869 if ((lpLinkHeader
->MagicStr
== 0x0000004CL
) && IsEqualIID(&lpLinkHeader
->MagicGuid
, &CLSID_ShellLink
))
871 lpLinkHeader
= HeapReAlloc(GetProcessHeap(), 0, lpLinkHeader
, LINK_HEADER_SIZE
+lpLinkHeader
->PidlSize
);
874 if (SUCCEEDED(IStream_Read(pLoadStream
, &(lpLinkHeader
->Pidl
), lpLinkHeader
->PidlSize
, &dwBytesRead
)))
876 if (pcheck (&lpLinkHeader
->Pidl
))
878 This
->pPidl
= ILClone (&lpLinkHeader
->Pidl
);
880 SHGetPathFromIDListA(&lpLinkHeader
->Pidl
, sTemp
);
881 This
->sPath
= heap_strdup( sTemp
);
883 This
->wHotKey
= lpLinkHeader
->wHotKey
;
884 FileTimeToSystemTime (&lpLinkHeader
->Time1
, &This
->time1
);
885 FileTimeToSystemTime (&lpLinkHeader
->Time2
, &This
->time2
);
886 FileTimeToSystemTime (&lpLinkHeader
->Time3
, &This
->time3
);
888 GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&This
->time1
, NULL
, sTemp
, 256);
889 TRACE("-- time1: %s\n", sTemp
);
890 GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&This
->time2
, NULL
, sTemp
, 256);
891 TRACE("-- time1: %s\n", sTemp
);
892 GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&This
->time3
, NULL
, sTemp
, 256);
893 TRACE("-- time1: %s\n", sTemp
);
902 WARN("stream contains no link!\n");
907 IStream_Release (pLoadStream
);
911 HeapFree(GetProcessHeap(), 0, lpLinkHeader
);
916 /************************************************************************
917 * IPersistStream_Save (IPersistStream)
919 static HRESULT WINAPI
IPersistStream_fnSave(
920 IPersistStream
* iface
,
924 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
926 TRACE("(%p) %p %x\n", This
, pOutStream
, fClearDirty
);
931 /************************************************************************
932 * IPersistStream_GetSizeMax (IPersistStream)
934 static HRESULT WINAPI
IPersistStream_fnGetSizeMax(
935 IPersistStream
* iface
,
936 ULARGE_INTEGER
* pcbSize
)
938 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
940 TRACE("(%p)\n", This
);
945 static ICOM_VTABLE(IPersistStream
) psvt
=
947 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
948 IPersistStream_fnQueryInterface
,
949 IPersistStream_fnAddRef
,
950 IPersistStream_fnRelease
,
951 IPersistStream_fnGetClassID
,
952 IPersistStream_fnIsDirty
,
953 IPersistStream_fnLoad
,
954 IPersistStream_fnSave
,
955 IPersistStream_fnGetSizeMax
958 /**************************************************************************
959 * IShellLink_Constructor
961 IShellLinkA
* IShellLink_Constructor(BOOL bUnicode
)
962 { IShellLinkImpl
* sl
;
964 sl
= (IShellLinkImpl
*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IShellLinkImpl
));
966 ICOM_VTBL(sl
) = &slvt
;
967 sl
->lpvtblw
= &slvtw
;
968 sl
->lpvtblPersistFile
= &pfvt
;
969 sl
->lpvtblPersistStream
= &psvt
;
971 TRACE("(%p)->()\n",sl
);
973 return bUnicode
? (IShellLinkA
*) &(sl
->lpvtblw
) : (IShellLinkA
*)sl
;
976 /**************************************************************************
977 * IShellLinkA_QueryInterface
979 static HRESULT WINAPI
IShellLinkA_fnQueryInterface( IShellLinkA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
981 ICOM_THIS(IShellLinkImpl
, iface
);
983 TRACE("(%p)->(\n\tIID:\t%s)\n",This
,debugstr_guid(riid
));
987 if(IsEqualIID(riid
, &IID_IUnknown
) ||
988 IsEqualIID(riid
, &IID_IShellLinkA
))
992 else if(IsEqualIID(riid
, &IID_IShellLinkW
))
994 *ppvObj
= (IShellLinkW
*)&(This
->lpvtblw
);
996 else if(IsEqualIID(riid
, &IID_IPersistFile
))
998 *ppvObj
= (IPersistFile
*)&(This
->lpvtblPersistFile
);
1000 else if(IsEqualIID(riid
, &IID_IPersistStream
))
1002 *ppvObj
= (IPersistStream
*)&(This
->lpvtblPersistStream
);
1007 IUnknown_AddRef((IUnknown
*)(*ppvObj
));
1008 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
1011 TRACE("-- Interface: E_NOINTERFACE\n");
1012 return E_NOINTERFACE
;
1014 /******************************************************************************
1015 * IShellLinkA_AddRef
1017 static ULONG WINAPI
IShellLinkA_fnAddRef(IShellLinkA
* iface
)
1019 ICOM_THIS(IShellLinkImpl
, iface
);
1021 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1024 return ++(This
->ref
);
1026 /******************************************************************************
1027 * IShellLinkA_Release
1029 static ULONG WINAPI
IShellLinkA_fnRelease(IShellLinkA
* iface
)
1031 ICOM_THIS(IShellLinkImpl
, iface
);
1033 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1037 { TRACE("-- destroying IShellLink(%p)\n",This
);
1040 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1043 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1046 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1048 if (This
->sDescription
)
1049 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1052 HeapFree(GetProcessHeap(),0,This
->sPath
);
1055 SHFree(This
->pPidl
);
1057 if (This
->lpFileStream
)
1058 IStream_Release(This
->lpFileStream
);
1062 HeapFree(GetProcessHeap(),0,This
);
1068 static HRESULT WINAPI
IShellLinkA_fnGetPath(IShellLinkA
* iface
, LPSTR pszFile
,INT cchMaxPath
, WIN32_FIND_DATAA
*pfd
, DWORD fFlags
)
1070 ICOM_THIS(IShellLinkImpl
, iface
);
1072 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n",This
, pszFile
, cchMaxPath
, pfd
, fFlags
, debugstr_a(This
->sPath
));
1075 lstrcpynA(pszFile
,This
->sPath
, cchMaxPath
);
1081 static HRESULT WINAPI
IShellLinkA_fnGetIDList(IShellLinkA
* iface
, LPITEMIDLIST
* ppidl
)
1083 ICOM_THIS(IShellLinkImpl
, iface
);
1085 TRACE("(%p)->(ppidl=%p)\n",This
, ppidl
);
1087 *ppidl
= ILClone(This
->pPidl
);
1090 static HRESULT WINAPI
IShellLinkA_fnSetIDList(IShellLinkA
* iface
, LPCITEMIDLIST pidl
)
1092 ICOM_THIS(IShellLinkImpl
, iface
);
1094 TRACE("(%p)->(pidl=%p)\n",This
, pidl
);
1097 SHFree(This
->pPidl
);
1098 This
->pPidl
= ILClone (pidl
);
1101 static HRESULT WINAPI
IShellLinkA_fnGetDescription(IShellLinkA
* iface
, LPSTR pszName
,INT cchMaxName
)
1103 ICOM_THIS(IShellLinkImpl
, iface
);
1105 FIXME("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1106 lstrcpynA(pszName
,"Description, FIXME",cchMaxName
);
1109 static HRESULT WINAPI
IShellLinkA_fnSetDescription(IShellLinkA
* iface
, LPCSTR pszName
)
1111 ICOM_THIS(IShellLinkImpl
, iface
);
1113 TRACE("(%p)->(pName=%s)\n", This
, pszName
);
1115 if (This
->sDescription
)
1116 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1117 if (!(This
->sDescription
= heap_strdup(pszName
)))
1118 return E_OUTOFMEMORY
;
1122 static HRESULT WINAPI
IShellLinkA_fnGetWorkingDirectory(IShellLinkA
* iface
, LPSTR pszDir
,INT cchMaxPath
)
1124 ICOM_THIS(IShellLinkImpl
, iface
);
1126 TRACE("(%p)->(%p len=%u)\n", This
, pszDir
, cchMaxPath
);
1128 lstrcpynA( pszDir
, This
->sWorkDir
? This
->sWorkDir
: "", cchMaxPath
);
1132 static HRESULT WINAPI
IShellLinkA_fnSetWorkingDirectory(IShellLinkA
* iface
, LPCSTR pszDir
)
1134 ICOM_THIS(IShellLinkImpl
, iface
);
1136 TRACE("(%p)->(dir=%s)\n",This
, pszDir
);
1139 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1140 if (!(This
->sWorkDir
= heap_strdup(pszDir
)))
1141 return E_OUTOFMEMORY
;
1145 static HRESULT WINAPI
IShellLinkA_fnGetArguments(IShellLinkA
* iface
, LPSTR pszArgs
,INT cchMaxPath
)
1147 ICOM_THIS(IShellLinkImpl
, iface
);
1149 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1151 lstrcpynA( pszArgs
, This
->sArgs
? This
->sArgs
: "", cchMaxPath
);
1155 static HRESULT WINAPI
IShellLinkA_fnSetArguments(IShellLinkA
* iface
, LPCSTR pszArgs
)
1157 ICOM_THIS(IShellLinkImpl
, iface
);
1159 TRACE("(%p)->(args=%s)\n",This
, pszArgs
);
1162 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1163 if (!(This
->sArgs
= heap_strdup(pszArgs
)))
1164 return E_OUTOFMEMORY
;
1168 static HRESULT WINAPI
IShellLinkA_fnGetHotkey(IShellLinkA
* iface
, WORD
*pwHotkey
)
1170 ICOM_THIS(IShellLinkImpl
, iface
);
1172 TRACE("(%p)->(%p)(0x%08x)\n",This
, pwHotkey
, This
->wHotKey
);
1174 *pwHotkey
= This
->wHotKey
;
1178 static HRESULT WINAPI
IShellLinkA_fnSetHotkey(IShellLinkA
* iface
, WORD wHotkey
)
1180 ICOM_THIS(IShellLinkImpl
, iface
);
1182 TRACE("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1184 This
->wHotKey
= wHotkey
;
1188 static HRESULT WINAPI
IShellLinkA_fnGetShowCmd(IShellLinkA
* iface
, INT
*piShowCmd
)
1190 ICOM_THIS(IShellLinkImpl
, iface
);
1192 FIXME("(%p)->(%p)\n",This
, piShowCmd
);
1196 static HRESULT WINAPI
IShellLinkA_fnSetShowCmd(IShellLinkA
* iface
, INT iShowCmd
)
1198 ICOM_THIS(IShellLinkImpl
, iface
);
1200 FIXME("(%p)->(showcmd=%x)\n",This
, iShowCmd
);
1203 static HRESULT WINAPI
IShellLinkA_fnGetIconLocation(IShellLinkA
* iface
, LPSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1205 ICOM_THIS(IShellLinkImpl
, iface
);
1207 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1209 lstrcpynA( pszIconPath
, This
->sIcoPath
? This
->sIcoPath
: "", cchIconPath
);
1210 *piIcon
= This
->iIcoNdx
;
1214 static HRESULT WINAPI
IShellLinkA_fnSetIconLocation(IShellLinkA
* iface
, LPCSTR pszIconPath
,INT iIcon
)
1216 ICOM_THIS(IShellLinkImpl
, iface
);
1218 TRACE("(%p)->(path=%s iicon=%u)\n",This
, pszIconPath
, iIcon
);
1221 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1222 if (!(This
->sIcoPath
= heap_strdup(pszIconPath
)))
1223 return E_OUTOFMEMORY
;
1224 This
->iIcoNdx
= iIcon
;
1228 static HRESULT WINAPI
IShellLinkA_fnSetRelativePath(IShellLinkA
* iface
, LPCSTR pszPathRel
, DWORD dwReserved
)
1230 ICOM_THIS(IShellLinkImpl
, iface
);
1232 FIXME("(%p)->(path=%s %lx)\n",This
, pszPathRel
, dwReserved
);
1235 static HRESULT WINAPI
IShellLinkA_fnResolve(IShellLinkA
* iface
, HWND hwnd
, DWORD fFlags
)
1237 ICOM_THIS(IShellLinkImpl
, iface
);
1239 FIXME("(%p)->(hwnd=%x flags=%lx)\n",This
, hwnd
, fFlags
);
1242 static HRESULT WINAPI
IShellLinkA_fnSetPath(IShellLinkA
* iface
, LPCSTR pszFile
)
1244 ICOM_THIS(IShellLinkImpl
, iface
);
1246 TRACE("(%p)->(path=%s)\n",This
, pszFile
);
1249 HeapFree(GetProcessHeap(), 0, This
->sPath
);
1250 if (!(This
->sPath
= heap_strdup(pszFile
)))
1251 return E_OUTOFMEMORY
;
1256 /**************************************************************************
1257 * IShellLink Implementation
1260 static ICOM_VTABLE(IShellLinkA
) slvt
=
1262 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1263 IShellLinkA_fnQueryInterface
,
1264 IShellLinkA_fnAddRef
,
1265 IShellLinkA_fnRelease
,
1266 IShellLinkA_fnGetPath
,
1267 IShellLinkA_fnGetIDList
,
1268 IShellLinkA_fnSetIDList
,
1269 IShellLinkA_fnGetDescription
,
1270 IShellLinkA_fnSetDescription
,
1271 IShellLinkA_fnGetWorkingDirectory
,
1272 IShellLinkA_fnSetWorkingDirectory
,
1273 IShellLinkA_fnGetArguments
,
1274 IShellLinkA_fnSetArguments
,
1275 IShellLinkA_fnGetHotkey
,
1276 IShellLinkA_fnSetHotkey
,
1277 IShellLinkA_fnGetShowCmd
,
1278 IShellLinkA_fnSetShowCmd
,
1279 IShellLinkA_fnGetIconLocation
,
1280 IShellLinkA_fnSetIconLocation
,
1281 IShellLinkA_fnSetRelativePath
,
1282 IShellLinkA_fnResolve
,
1283 IShellLinkA_fnSetPath
1287 /**************************************************************************
1288 * IShellLinkW_fnQueryInterface
1290 static HRESULT WINAPI
IShellLinkW_fnQueryInterface(
1291 IShellLinkW
* iface
, REFIID riid
, LPVOID
*ppvObj
)
1293 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1295 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObj
);
1298 /******************************************************************************
1299 * IShellLinkW_fnAddRef
1301 static ULONG WINAPI
IShellLinkW_fnAddRef(IShellLinkW
* iface
)
1303 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1305 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1307 return IShellLinkA_AddRef((IShellLinkA
*)This
);
1309 /******************************************************************************
1310 * IShellLinkW_fnRelease
1313 static ULONG WINAPI
IShellLinkW_fnRelease(IShellLinkW
* iface
)
1315 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1317 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1319 return IShellLinkA_Release((IShellLinkA
*)This
);
1322 static HRESULT WINAPI
IShellLinkW_fnGetPath(IShellLinkW
* iface
, LPWSTR pszFile
,INT cchMaxPath
, WIN32_FIND_DATAA
*pfd
, DWORD fFlags
)
1324 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1326 FIXME("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This
, pszFile
, cchMaxPath
, pfd
, fFlags
);
1327 MultiByteToWideChar( CP_ACP
, 0, "c:\\foo.bar", -1, pszFile
, cchMaxPath
);
1331 static HRESULT WINAPI
IShellLinkW_fnGetIDList(IShellLinkW
* iface
, LPITEMIDLIST
* ppidl
)
1333 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1335 FIXME("(%p)->(ppidl=%p)\n",This
, ppidl
);
1336 *ppidl
= _ILCreateDesktop();
1340 static HRESULT WINAPI
IShellLinkW_fnSetIDList(IShellLinkW
* iface
, LPCITEMIDLIST pidl
)
1342 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1344 FIXME("(%p)->(pidl=%p)\n",This
, pidl
);
1348 static HRESULT WINAPI
IShellLinkW_fnGetDescription(IShellLinkW
* iface
, LPWSTR pszName
,INT cchMaxName
)
1350 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1352 FIXME("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1353 MultiByteToWideChar( CP_ACP
, 0, "Description, FIXME", -1, pszName
, cchMaxName
);
1357 static HRESULT WINAPI
IShellLinkW_fnSetDescription(IShellLinkW
* iface
, LPCWSTR pszName
)
1359 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1361 TRACE("(%p)->(desc=%s)\n",This
, debugstr_w(pszName
));
1363 if (This
->sDescription
)
1364 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1365 if (!(This
->sDescription
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszName
)))
1366 return E_OUTOFMEMORY
;
1371 static HRESULT WINAPI
IShellLinkW_fnGetWorkingDirectory(IShellLinkW
* iface
, LPWSTR pszDir
,INT cchMaxPath
)
1373 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1375 TRACE("(%p)->(%p len %u)\n", This
, pszDir
, cchMaxPath
);
1377 MultiByteToWideChar( CP_ACP
, 0, This
->sWorkDir
? This
->sWorkDir
: "", -1, pszDir
, cchMaxPath
);
1382 static HRESULT WINAPI
IShellLinkW_fnSetWorkingDirectory(IShellLinkW
* iface
, LPCWSTR pszDir
)
1384 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1386 TRACE("(%p)->(dir=%s)\n",This
, debugstr_w(pszDir
));
1389 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1390 if (!(This
->sWorkDir
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszDir
)))
1391 return E_OUTOFMEMORY
;
1396 static HRESULT WINAPI
IShellLinkW_fnGetArguments(IShellLinkW
* iface
, LPWSTR pszArgs
,INT cchMaxPath
)
1398 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1400 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1402 MultiByteToWideChar( CP_ACP
, 0, This
->sArgs
? This
->sArgs
: "", -1, pszArgs
, cchMaxPath
);
1407 static HRESULT WINAPI
IShellLinkW_fnSetArguments(IShellLinkW
* iface
, LPCWSTR pszArgs
)
1409 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1411 TRACE("(%p)->(args=%s)\n",This
, debugstr_w(pszArgs
));
1414 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1415 if (!(This
->sArgs
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszArgs
)))
1416 return E_OUTOFMEMORY
;
1421 static HRESULT WINAPI
IShellLinkW_fnGetHotkey(IShellLinkW
* iface
, WORD
*pwHotkey
)
1423 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1425 FIXME("(%p)->(%p)\n",This
, pwHotkey
);
1430 static HRESULT WINAPI
IShellLinkW_fnSetHotkey(IShellLinkW
* iface
, WORD wHotkey
)
1432 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1434 FIXME("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1438 static HRESULT WINAPI
IShellLinkW_fnGetShowCmd(IShellLinkW
* iface
, INT
*piShowCmd
)
1440 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1442 FIXME("(%p)->(%p)\n",This
, piShowCmd
);
1447 static HRESULT WINAPI
IShellLinkW_fnSetShowCmd(IShellLinkW
* iface
, INT iShowCmd
)
1449 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1451 FIXME("(%p)->(showcmd=%x)\n",This
, iShowCmd
);
1455 static HRESULT WINAPI
IShellLinkW_fnGetIconLocation(IShellLinkW
* iface
, LPWSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1457 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1459 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1461 MultiByteToWideChar( CP_ACP
, 0, This
->sIcoPath
? This
->sIcoPath
: "", -1, pszIconPath
, cchIconPath
);
1462 *piIcon
= This
->iIcoNdx
;
1467 static HRESULT WINAPI
IShellLinkW_fnSetIconLocation(IShellLinkW
* iface
, LPCWSTR pszIconPath
,INT iIcon
)
1469 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1471 TRACE("(%p)->(path=%s iicon=%u)\n",This
, debugstr_w(pszIconPath
), iIcon
);
1474 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1475 if (!(This
->sIcoPath
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszIconPath
)))
1476 return E_OUTOFMEMORY
;
1477 This
->iIcoNdx
= iIcon
;
1482 static HRESULT WINAPI
IShellLinkW_fnSetRelativePath(IShellLinkW
* iface
, LPCWSTR pszPathRel
, DWORD dwReserved
)
1484 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1486 FIXME("(%p)->(path=%s %lx)\n",This
, debugstr_w(pszPathRel
), dwReserved
);
1490 static HRESULT WINAPI
IShellLinkW_fnResolve(IShellLinkW
* iface
, HWND hwnd
, DWORD fFlags
)
1492 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1494 FIXME("(%p)->(hwnd=%x flags=%lx)\n",This
, hwnd
, fFlags
);
1498 static HRESULT WINAPI
IShellLinkW_fnSetPath(IShellLinkW
* iface
, LPCWSTR pszFile
)
1500 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1502 TRACE("(%p)->(path=%s)\n",This
, debugstr_w(pszFile
));
1505 HeapFree(GetProcessHeap(), 0, This
->sPath
);
1506 if (!(This
->sPath
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszFile
)))
1507 return E_OUTOFMEMORY
;
1512 /**************************************************************************
1513 * IShellLinkW Implementation
1516 static ICOM_VTABLE(IShellLinkW
) slvtw
=
1518 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1519 IShellLinkW_fnQueryInterface
,
1520 IShellLinkW_fnAddRef
,
1521 IShellLinkW_fnRelease
,
1522 IShellLinkW_fnGetPath
,
1523 IShellLinkW_fnGetIDList
,
1524 IShellLinkW_fnSetIDList
,
1525 IShellLinkW_fnGetDescription
,
1526 IShellLinkW_fnSetDescription
,
1527 IShellLinkW_fnGetWorkingDirectory
,
1528 IShellLinkW_fnSetWorkingDirectory
,
1529 IShellLinkW_fnGetArguments
,
1530 IShellLinkW_fnSetArguments
,
1531 IShellLinkW_fnGetHotkey
,
1532 IShellLinkW_fnSetHotkey
,
1533 IShellLinkW_fnGetShowCmd
,
1534 IShellLinkW_fnSetShowCmd
,
1535 IShellLinkW_fnGetIconLocation
,
1536 IShellLinkW_fnSetIconLocation
,
1537 IShellLinkW_fnSetRelativePath
,
1538 IShellLinkW_fnResolve
,
1539 IShellLinkW_fnSetPath