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
29 #ifdef HAVE_SYS_WAIT_H
30 # include <sys/wait.h>
32 #include "wine/debug.h"
33 #include "wine/port.h"
40 #include "undocshell.h"
41 #include "bitmaps/wine.xpm"
45 #include "shell32_main.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
50 /* link file formats */
54 /* flag1: lnk elements: simple link has 0x0B */
62 #define MAXIMIZED 0x03
63 #define MINIMIZED 0x07
65 typedef struct _LINK_HEADER
66 { DWORD MagicStr
; /* 0x00 'L','\0','\0','\0' */
67 GUID MagicGuid
; /* 0x04 is CLSID_ShellLink */
68 DWORD Flag1
; /* 0x14 describes elements following */
69 DWORD Flag2
; /* 0x18 */
70 FILETIME Time1
; /* 0x1c */
71 FILETIME Time2
; /* 0x24 */
72 FILETIME Time3
; /* 0x2c */
73 DWORD Unknown1
; /* 0x34 */
74 DWORD Unknown2
; /* 0x38 icon number */
75 DWORD fStartup
; /* 0x3c startup type */
76 DWORD wHotKey
; /* 0x40 hotkey */
77 DWORD Unknown5
; /* 0x44 */
78 DWORD Unknown6
; /* 0x48 */
79 USHORT PidlSize
; /* 0x4c */
80 ITEMIDLIST Pidl
; /* 0x4e */
81 } LINK_HEADER
, * PLINK_HEADER
;
83 #define LINK_HEADER_SIZE (sizeof(LINK_HEADER)-sizeof(ITEMIDLIST))
102 GRPICONDIRENTRY idEntries
[1];
133 static ICOM_VTABLE(IShellLinkA
) slvt
;
134 static ICOM_VTABLE(IShellLinkW
) slvtw
;
135 static ICOM_VTABLE(IPersistFile
) pfvt
;
136 static ICOM_VTABLE(IPersistStream
) psvt
;
138 /* IShellLink Implementation */
142 ICOM_VFIELD(IShellLinkA
);
145 ICOM_VTABLE(IShellLinkW
)* lpvtblw
;
146 ICOM_VTABLE(IPersistFile
)* lpvtblPersistFile
;
147 ICOM_VTABLE(IPersistStream
)* lpvtblPersistStream
;
149 /* internal stream of the IPersistFile interface */
150 IStream
* lpFileStream
;
152 /* data structures according to the informations in the lnk */
167 #define _IShellLinkW_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblw)))
168 #define _ICOM_THIS_From_IShellLinkW(class, name) class* This = (class*)(((char*)name)-_IShellLinkW_Offset);
170 #define _IPersistFile_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistFile)))
171 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset);
173 #define _IPersistStream_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistStream)))
174 #define _ICOM_THIS_From_IPersistStream(class, name) class* This = (class*)(((char*)name)-_IPersistStream_Offset);
175 #define _IPersistStream_From_ICOM_THIS(class, name) class* StreamThis = (class*)(((char*)name)+_IPersistStream_Offset);
178 /* strdup on the process heap */
179 inline static LPSTR
heap_strdup( LPCSTR str
)
181 INT len
= strlen(str
) + 1;
182 LPSTR p
= HeapAlloc( GetProcessHeap(), 0, len
);
183 if (p
) memcpy( p
, str
, len
);
188 /**************************************************************************
189 * IPersistFile_QueryInterface
191 static HRESULT WINAPI
IPersistFile_fnQueryInterface(
196 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
198 TRACE("(%p)\n",This
);
200 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObj
);
203 /******************************************************************************
204 * IPersistFile_AddRef
206 static ULONG WINAPI
IPersistFile_fnAddRef(IPersistFile
* iface
)
208 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
210 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
212 return IShellLinkA_AddRef((IShellLinkA
*)This
);
214 /******************************************************************************
215 * IPersistFile_Release
217 static ULONG WINAPI
IPersistFile_fnRelease(IPersistFile
* iface
)
219 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
221 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
223 return IShellLinkA_Release((IShellLinkA
*)This
);
226 static HRESULT WINAPI
IPersistFile_fnGetClassID(IPersistFile
* iface
, CLSID
*pClassID
)
228 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
229 FIXME("(%p)\n",This
);
232 static HRESULT WINAPI
IPersistFile_fnIsDirty(IPersistFile
* iface
)
234 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
235 FIXME("(%p)\n",This
);
238 static HRESULT WINAPI
IPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
240 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
)
241 _IPersistStream_From_ICOM_THIS(IPersistStream
, This
)
243 LPSTR sFile
= HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName
);
244 HRESULT hRet
= E_FAIL
;
246 TRACE("(%p, %s)\n",This
, sFile
);
249 if (This
->lpFileStream
)
250 IStream_Release(This
->lpFileStream
);
252 if SUCCEEDED(CreateStreamOnFile(sFile
, &(This
->lpFileStream
)))
254 if SUCCEEDED (IPersistStream_Load(StreamThis
, This
->lpFileStream
))
264 /* Icon extraction routines
266 * FIXME: should use PrivateExtractIcons and friends
267 * FIXME: should not use stdio
270 static BOOL
SaveIconResAsXPM(const BITMAPINFO
*pIcon
, const char *szXPMFileName
)
280 BOOL aColorUsed
[256] = {0};
284 if (!((pIcon
->bmiHeader
.biBitCount
== 4) || (pIcon
->bmiHeader
.biBitCount
== 8)))
287 if (!(fXPMFile
= fopen(szXPMFileName
, "w")))
290 nHeight
= pIcon
->bmiHeader
.biHeight
/ 2;
291 nXORWidthBytes
= 4 * ((pIcon
->bmiHeader
.biWidth
* pIcon
->bmiHeader
.biBitCount
/ 32)
292 + ((pIcon
->bmiHeader
.biWidth
* pIcon
->bmiHeader
.biBitCount
% 32) > 0));
293 nANDWidthBytes
= 4 * ((pIcon
->bmiHeader
.biWidth
/ 32)
294 + ((pIcon
->bmiHeader
.biWidth
% 32) > 0));
295 b8BitColors
= pIcon
->bmiHeader
.biBitCount
== 8;
296 nColors
= pIcon
->bmiHeader
.biClrUsed
? pIcon
->bmiHeader
.biClrUsed
297 : 1 << pIcon
->bmiHeader
.biBitCount
;
298 pXOR
= (BYTE
*) pIcon
+ sizeof (BITMAPINFOHEADER
) + (nColors
* sizeof (RGBQUAD
));
299 pAND
= pXOR
+ nHeight
* nXORWidthBytes
;
301 #define MASK(x,y) (pAND[(x) / 8 + (nHeight - (y) - 1) * nANDWidthBytes] & (1 << (7 - (x) % 8)))
302 #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)
304 for (i
= 0; i
< nHeight
; i
++)
305 for (j
= 0; j
< pIcon
->bmiHeader
.biWidth
; j
++)
306 if (!aColorUsed
[COLOR(j
,i
)] && !MASK(j
,i
))
308 aColorUsed
[COLOR(j
,i
)] = TRUE
;
312 if (fprintf(fXPMFile
, "/* XPM */\nstatic char *icon[] = {\n") <= 0)
314 if (fprintf(fXPMFile
, "\"%d %d %d %d\",\n",
315 (int) pIcon
->bmiHeader
.biWidth
, nHeight
, nColorsUsed
+ 1, 2) <=0)
318 for (i
= 0; i
< nColors
; i
++)
320 if (fprintf(fXPMFile
, "\"%.2X c #%.2X%.2X%.2X\",\n", i
, pIcon
->bmiColors
[i
].rgbRed
,
321 pIcon
->bmiColors
[i
].rgbGreen
, pIcon
->bmiColors
[i
].rgbBlue
) <= 0)
323 if (fprintf(fXPMFile
, "\" c None\"") <= 0)
326 for (i
= 0; i
< nHeight
; i
++)
328 if (fprintf(fXPMFile
, ",\n\"") <= 0)
330 for (j
= 0; j
< pIcon
->bmiHeader
.biWidth
; j
++)
334 if (fprintf(fXPMFile
, " ") <= 0)
338 if (fprintf(fXPMFile
, "%.2X", COLOR(j
,i
)) <= 0)
341 if (fprintf(fXPMFile
, "\"") <= 0)
344 if (fprintf(fXPMFile
, "};\n") <= 0)
355 unlink( szXPMFileName
);
359 static BOOL CALLBACK
EnumResNameProc(HANDLE hModule
, const char *lpszType
, char *lpszName
, LONG lParam
)
361 ENUMRESSTRUCT
*sEnumRes
= (ENUMRESSTRUCT
*) lParam
;
363 if (!sEnumRes
->nIndex
--)
365 *sEnumRes
->pResInfo
= FindResourceA(hModule
, lpszName
, RT_GROUP_ICONA
);
372 static int ExtractFromEXEDLL(const char *szFileName
, int nIndex
, const char *szXPMFileName
)
378 GRPICONDIR
*pIconDir
;
380 ENUMRESSTRUCT sEnumRes
;
385 if (!(hModule
= LoadLibraryExA(szFileName
, 0, LOAD_LIBRARY_AS_DATAFILE
)))
387 TRACE("LoadLibraryExA (%s) failed, error %ld\n", szFileName
, GetLastError());
393 hResInfo
= FindResourceA(hModule
, MAKEINTRESOURCEA(-nIndex
), RT_GROUP_ICONA
);
394 TRACE("FindResourceA (%s) called, return 0x%x, error %ld\n", szFileName
, hResInfo
, GetLastError());
398 sEnumRes
.pResInfo
= &hResInfo
;
399 sEnumRes
.nIndex
= nIndex
;
400 if (EnumResourceNamesA(hModule
, RT_GROUP_ICONA
, &EnumResNameProc
, (LONG
) &sEnumRes
))
402 TRACE("EnumResourceNamesA failed, error %ld\n", GetLastError());
409 TRACE("ExtractFromEXEDLL failed, error %ld\n", GetLastError());
413 if (!(hResData
= LoadResource(hModule
, hResInfo
)))
415 TRACE("LoadResource failed, error %ld\n", GetLastError());
418 if (!(pIconDir
= LockResource(hResData
)))
420 TRACE("LockResource failed, error %ld\n", GetLastError());
424 for (i
= 0; i
< pIconDir
->idCount
; i
++)
425 if ((pIconDir
->idEntries
[i
].wBitCount
>= nMaxBits
) && (pIconDir
->idEntries
[i
].wBitCount
<= 8))
427 if (pIconDir
->idEntries
[i
].wBitCount
> nMaxBits
)
429 nMaxBits
= pIconDir
->idEntries
[i
].wBitCount
;
432 if ((pIconDir
->idEntries
[i
].bHeight
* pIconDir
->idEntries
[i
].bWidth
) > nMax
)
434 lpName
= MAKEINTRESOURCEA(pIconDir
->idEntries
[i
].nID
);
435 nMax
= pIconDir
->idEntries
[i
].bHeight
* pIconDir
->idEntries
[i
].bWidth
;
439 FreeResource(hResData
);
441 if (!(hResInfo
= FindResourceA(hModule
, lpName
, RT_ICONA
)))
443 TRACE("Second FindResourceA failed, error %ld\n", GetLastError());
446 if (!(hResData
= LoadResource(hModule
, hResInfo
)))
448 TRACE("Second LoadResource failed, error %ld\n", GetLastError());
451 if (!(pIcon
= LockResource(hResData
)))
453 TRACE("Second LockResource failed, error %ld\n", GetLastError());
457 if(!SaveIconResAsXPM(pIcon
, szXPMFileName
))
459 TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
463 FreeResource(hResData
);
464 FreeLibrary(hModule
);
469 FreeResource(hResData
);
471 FreeLibrary(hModule
);
476 /* get the Unix file name for a given path, allocating the string */
477 inline static char *get_unix_file_name( const char *dos
)
479 char buffer
[MAX_PATH
];
481 if (!wine_get_unix_file_name( dos
, buffer
, sizeof(buffer
) )) return NULL
;
482 return heap_strdup( buffer
);
485 static int ExtractFromICO(const char *szFileName
, const char *szXPMFileName
)
489 ICONDIRENTRY
*pIconDirEntry
;
496 filename
= get_unix_file_name(szFileName
);
497 if (!(fICOFile
= fopen(filename
, "r")))
500 if (fread(&iconDir
, sizeof (ICONDIR
), 1, fICOFile
) != 1)
502 if ((iconDir
.idReserved
!= 0) || (iconDir
.idType
!= 1))
505 if ((pIconDirEntry
= malloc(iconDir
.idCount
* sizeof (ICONDIRENTRY
))) == NULL
)
507 if (fread(pIconDirEntry
, sizeof (ICONDIRENTRY
), iconDir
.idCount
, fICOFile
) != iconDir
.idCount
)
510 for (i
= 0; i
< iconDir
.idCount
; i
++)
511 if ((pIconDirEntry
[i
].bHeight
* pIconDirEntry
[i
].bWidth
) > nMax
)
514 nMax
= pIconDirEntry
[i
].bHeight
* pIconDirEntry
[i
].bWidth
;
516 if ((pIcon
= malloc(pIconDirEntry
[nIndex
].dwBytesInRes
)) == NULL
)
518 if (fseek(fICOFile
, pIconDirEntry
[nIndex
].dwImageOffset
, SEEK_SET
))
520 if (fread(pIcon
, pIconDirEntry
[nIndex
].dwBytesInRes
, 1, fICOFile
) != 1)
523 if(!SaveIconResAsXPM(pIcon
, szXPMFileName
))
539 HeapFree(GetProcessHeap(), 0, filename
);
543 static BOOL
create_default_icon( const char *filename
)
548 if (!(fXPM
= fopen(filename
, "w"))) return FALSE
;
549 fprintf(fXPM
, "/* XPM */\nstatic char * icon[] = {");
550 for (i
= 0; i
< sizeof(wine_xpm
)/sizeof(wine_xpm
[0]); i
++)
551 fprintf( fXPM
, "\n\"%s\",", wine_xpm
[i
]);
552 fprintf( fXPM
, "};\n" );
557 /* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */
558 static char *extract_icon( const char *path
, int index
)
560 int fd
, nodefault
= 1;
561 char *filename
, tmpfn
[25];
563 strcpy(tmpfn
,"/tmp/icon.XXXXXX");
564 fd
= mkstemp( tmpfn
);
567 filename
= heap_strdup( tmpfn
);
568 close(fd
); /* not needed */
570 /* If icon path begins with a '*' then this is a deferred call */
576 if (ExtractFromEXEDLL( path
, index
, filename
)) return filename
;
577 if (ExtractFromICO( path
, filename
)) return filename
;
579 if (create_default_icon( filename
)) return filename
;
580 HeapFree( GetProcessHeap(), 0, filename
);
584 /* This escapes \ in filenames */
589 narg
= HeapAlloc(GetProcessHeap(),0,2*strlen(arg
)+2);
594 *x
++='\\'; /* escape \ */
601 static HRESULT WINAPI
IPersistFile_fnSave(IPersistFile
* iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
603 HRESULT ret
= NOERROR
;
605 char buffer
[MAX_PATH
], buff2
[MAX_PATH
], ascii_filename
[MAX_PATH
];
606 char *filename
, *link_name
, *p
;
607 char *shell_link_app
= NULL
;
608 char *icon_name
= NULL
;
609 char *work_dir
= NULL
;
610 char *escaped_path
= NULL
;
611 char *escaped_args
= NULL
;
615 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
617 TRACE("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
619 if (!pszFileName
|| !This
->sPath
)
620 return ERROR_UNKNOWN
;
622 /* check for .exe extension */
623 if (!(p
= strrchr( This
->sPath
, '.' ))) return NOERROR
;
624 if (strchr( p
, '\\' ) || strchr( p
, '/' )) return NOERROR
;
625 if (strcasecmp( p
, ".exe" )) return NOERROR
;
627 /* check if ShellLinker configured */
629 if (!RegOpenKeyExA( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Wine\\Config\\Wine",
630 0, KEY_ALL_ACCESS
, &hkey
))
632 DWORD type
, count
= sizeof(buffer
);
633 if (RegQueryValueExA( hkey
, "ShellLinker", 0, &type
, buffer
, &count
)) buffer
[0] = 0;
636 if (!*buffer
) return NOERROR
;
637 shell_link_app
= heap_strdup( buffer
);
639 if (!WideCharToMultiByte( CP_ACP
, 0, pszFileName
, -1, ascii_filename
, sizeof(ascii_filename
), NULL
, NULL
))
640 return ERROR_UNKNOWN
;
641 GetFullPathNameA( ascii_filename
, sizeof(buff2
), buff2
, NULL
);
642 filename
= heap_strdup( buff2
);
644 if (SHGetSpecialFolderPathA( 0, buffer
, CSIDL_STARTUP
, FALSE
))
646 /* ignore startup for now */
647 if (!strncasecmp( filename
, buffer
, strlen(buffer
) )) goto done
;
649 if (SHGetSpecialFolderPathA( 0, buffer
, CSIDL_DESKTOPDIRECTORY
, FALSE
))
651 if (!strncasecmp( filename
, buffer
, strlen(buffer
) ))
653 link_name
= filename
+ strlen(buffer
);
658 if (SHGetSpecialFolderPathA( 0, buffer
, CSIDL_STARTMENU
, FALSE
))
660 if (!strncasecmp( filename
, buffer
, strlen(buffer
) ))
662 link_name
= filename
+ strlen(buffer
);
670 /* make link name a Unix name */
671 for (p
= link_name
; *p
; p
++) if (*p
== '\\') *p
= '/';
672 /* strip leading slashes */
673 while (*link_name
== '/') link_name
++;
674 /* remove extension */
675 if ((p
= strrchr( link_name
, '.' ))) *p
= 0;
677 /* convert app working dir */
678 if (This
->sWorkDir
) work_dir
= get_unix_file_name( This
->sWorkDir
);
680 /* extract the icon */
681 if (!(icon_name
= extract_icon( This
->sIcoPath
&& strlen(This
->sIcoPath
) ?
682 This
->sIcoPath
: This
->sPath
,
685 /* Couldn't extract icon -- defer this menu entry to runonce. */
689 TRACE("Deferring icon creation to reboot.\n");
690 if (RegCreateKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce", 0,
691 NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hRunOnce
, NULL
) != ERROR_SUCCESS
)
696 buffer
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
* 3 + (This
->sArgs
? strlen(This
->sArgs
) : 0) +
697 (This
->sDescription
? strlen(This
->sDescription
) : 0) + 200);
698 sprintf(buffer
, "link:%s\xff*%s\xff%d\xff%s\xff%s\xff%s", This
->sPath
, This
->sIcoPath
, This
->iIcoNdx
,
699 This
->sArgs
? This
->sArgs
: "", This
->sDescription
? This
->sDescription
: "",
700 This
->sWorkDir
? This
->sWorkDir
: "");
701 if (RegSetValueExA(hRunOnce
, ascii_filename
, 0, REG_SZ
, buffer
, strlen(buffer
) + 1) != ERROR_SUCCESS
)
703 HeapFree(GetProcessHeap(), 0, buffer
);
704 RegCloseKey(hRunOnce
);
708 HeapFree(GetProcessHeap(), 0, buffer
);
709 RegCloseKey(hRunOnce
);
713 TRACE("linker app='%s' link='%s' mode=%s path='%s' args='%s' icon='%s' workdir='%s' descr='%s'\n",
714 shell_link_app
, link_name
, bDesktop
? "desktop" : "menu", This
->sPath
,
715 This
->sArgs
? This
->sArgs
: "", icon_name
, work_dir
? work_dir
: "",
716 This
->sDescription
? This
->sDescription
: "" );
718 if ((pid
= fork()) == -1) goto done
;
720 escaped_path
= escape(This
->sPath
);
722 escaped_args
= escape(This
->sArgs
);
728 argv
[pos
++] = shell_link_app
;
729 argv
[pos
++] = "--link";
730 argv
[pos
++] = link_name
;
731 argv
[pos
++] = "--path";
732 argv
[pos
++] = escaped_path
;
733 argv
[pos
++] = bDesktop
? "--desktop" : "--menu";
734 if (This
->sArgs
&& strlen(This
->sArgs
))
736 argv
[pos
++] = "--args";
737 argv
[pos
++] = escaped_args
;
741 argv
[pos
++] = "--icon";
742 argv
[pos
++] = icon_name
;
744 if (This
->sWorkDir
&& strlen(This
->sWorkDir
))
746 argv
[pos
++] = "--workdir";
747 argv
[pos
++] = work_dir
;
749 if (This
->sDescription
&& strlen(This
->sDescription
))
751 argv
[pos
++] = "--descr";
752 argv
[pos
++] = This
->sDescription
;
755 execvp( shell_link_app
, argv
);
759 while (waitpid( pid
, &status
, 0 ) == -1)
767 if (status
) ret
= E_ACCESSDENIED
;
770 if (icon_name
) unlink( icon_name
);
771 HeapFree( GetProcessHeap(), 0, shell_link_app
);
772 HeapFree( GetProcessHeap(), 0, filename
);
773 HeapFree( GetProcessHeap(), 0, icon_name
);
774 HeapFree( GetProcessHeap(), 0, work_dir
);
775 if (escaped_args
) HeapFree( GetProcessHeap(), 0, escaped_args
);
776 if (escaped_path
) HeapFree( GetProcessHeap(), 0, escaped_path
);
780 static HRESULT WINAPI
IPersistFile_fnSaveCompleted(IPersistFile
* iface
, LPCOLESTR pszFileName
)
782 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
783 FIXME("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
786 static HRESULT WINAPI
IPersistFile_fnGetCurFile(IPersistFile
* iface
, LPOLESTR
*ppszFileName
)
788 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
789 FIXME("(%p)\n",This
);
793 static ICOM_VTABLE(IPersistFile
) pfvt
=
795 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
796 IPersistFile_fnQueryInterface
,
797 IPersistFile_fnAddRef
,
798 IPersistFile_fnRelease
,
799 IPersistFile_fnGetClassID
,
800 IPersistFile_fnIsDirty
,
803 IPersistFile_fnSaveCompleted
,
804 IPersistFile_fnGetCurFile
807 /************************************************************************
808 * IPersistStream_QueryInterface
810 static HRESULT WINAPI
IPersistStream_fnQueryInterface(
811 IPersistStream
* iface
,
815 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
817 TRACE("(%p)\n",This
);
819 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvoid
);
822 /************************************************************************
823 * IPersistStream_Release
825 static ULONG WINAPI
IPersistStream_fnRelease(
826 IPersistStream
* iface
)
828 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
830 TRACE("(%p)\n",This
);
832 return IShellLinkA_Release((IShellLinkA
*)This
);
835 /************************************************************************
836 * IPersistStream_AddRef
838 static ULONG WINAPI
IPersistStream_fnAddRef(
839 IPersistStream
* iface
)
841 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
843 TRACE("(%p)\n",This
);
845 return IShellLinkA_AddRef((IShellLinkA
*)This
);
848 /************************************************************************
849 * IPersistStream_GetClassID
852 static HRESULT WINAPI
IPersistStream_fnGetClassID(
853 IPersistStream
* iface
,
856 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
858 TRACE("(%p)\n", This
);
863 /* memcpy(pClassID, &CLSID_???, sizeof(CLSID_???)); */
868 /************************************************************************
869 * IPersistStream_IsDirty (IPersistStream)
871 static HRESULT WINAPI
IPersistStream_fnIsDirty(
872 IPersistStream
* iface
)
874 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
876 TRACE("(%p)\n", This
);
880 /************************************************************************
881 * IPersistStream_Load (IPersistStream)
884 static HRESULT WINAPI
IPersistStream_fnLoad(
885 IPersistStream
* iface
,
886 IStream
* pLoadStream
)
888 PLINK_HEADER lpLinkHeader
= HeapAlloc(GetProcessHeap(), 0, LINK_HEADER_SIZE
);
891 char sTemp
[MAX_PATH
];
893 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
895 TRACE("(%p)(%p)\n", This
, pLoadStream
);
899 return STG_E_INVALIDPOINTER
;
902 IStream_AddRef (pLoadStream
);
907 if (!(SUCCEEDED(IStream_Read(pLoadStream
, lpLinkHeader
, LINK_HEADER_SIZE
, &dwBytesRead
))))
910 if (dwBytesRead
!= LINK_HEADER_SIZE
)
913 if ( (lpLinkHeader
->MagicStr
!= 0x0000004CL
) || !IsEqualIID(&lpLinkHeader
->MagicGuid
, &CLSID_ShellLink
) )
916 if(lpLinkHeader
->PidlSize
)
918 lpLinkHeader
= HeapReAlloc(GetProcessHeap(), 0, lpLinkHeader
, LINK_HEADER_SIZE
+lpLinkHeader
->PidlSize
);
922 if (!(SUCCEEDED(IStream_Read(pLoadStream
, &(lpLinkHeader
->Pidl
), lpLinkHeader
->PidlSize
, &dwBytesRead
))))
924 if(dwBytesRead
!= lpLinkHeader
->PidlSize
)
927 if (pcheck (&lpLinkHeader
->Pidl
))
929 This
->pPidl
= ILClone (&lpLinkHeader
->Pidl
);
931 SHGetPathFromIDListA(&lpLinkHeader
->Pidl
, sTemp
);
932 This
->sPath
= heap_strdup( sTemp
);
935 This
->wHotKey
= lpLinkHeader
->wHotKey
;
936 FileTimeToSystemTime (&lpLinkHeader
->Time1
, &This
->time1
);
937 FileTimeToSystemTime (&lpLinkHeader
->Time2
, &This
->time2
);
938 FileTimeToSystemTime (&lpLinkHeader
->Time3
, &This
->time3
);
940 GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&This
->time1
, NULL
, sTemp
, 256);
941 TRACE("-- time1: %s\n", sTemp
);
942 GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&This
->time2
, NULL
, sTemp
, 256);
943 TRACE("-- time1: %s\n", sTemp
);
944 GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&This
->time3
, NULL
, sTemp
, 256);
945 TRACE("-- time1: %s\n", sTemp
);
951 IStream_Release (pLoadStream
);
955 HeapFree(GetProcessHeap(), 0, lpLinkHeader
);
960 /************************************************************************
961 * IPersistStream_Save (IPersistStream)
963 static HRESULT WINAPI
IPersistStream_fnSave(
964 IPersistStream
* iface
,
968 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
970 TRACE("(%p) %p %x\n", This
, pOutStream
, fClearDirty
);
975 /************************************************************************
976 * IPersistStream_GetSizeMax (IPersistStream)
978 static HRESULT WINAPI
IPersistStream_fnGetSizeMax(
979 IPersistStream
* iface
,
980 ULARGE_INTEGER
* pcbSize
)
982 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
984 TRACE("(%p)\n", This
);
989 static ICOM_VTABLE(IPersistStream
) psvt
=
991 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
992 IPersistStream_fnQueryInterface
,
993 IPersistStream_fnAddRef
,
994 IPersistStream_fnRelease
,
995 IPersistStream_fnGetClassID
,
996 IPersistStream_fnIsDirty
,
997 IPersistStream_fnLoad
,
998 IPersistStream_fnSave
,
999 IPersistStream_fnGetSizeMax
1002 /**************************************************************************
1003 * IShellLink_Constructor
1005 HRESULT WINAPI
IShellLink_Constructor (
1006 IUnknown
* pUnkOuter
,
1010 IShellLinkImpl
* sl
;
1012 TRACE("unkOut=%p riid=%s\n",pUnkOuter
, debugstr_guid(riid
));
1016 if(pUnkOuter
) return CLASS_E_NOAGGREGATION
;
1017 sl
= (IShellLinkImpl
*) LocalAlloc(GMEM_ZEROINIT
,sizeof(IShellLinkImpl
));
1018 if (!sl
) return E_OUTOFMEMORY
;
1021 ICOM_VTBL(sl
) = &slvt
;
1022 sl
->lpvtblw
= &slvtw
;
1023 sl
->lpvtblPersistFile
= &pfvt
;
1024 sl
->lpvtblPersistStream
= &psvt
;
1026 TRACE("(%p)->()\n",sl
);
1028 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1029 IsEqualIID(riid
, &IID_IShellLinkA
))
1031 else if (IsEqualIID(riid
, &IID_IShellLinkW
))
1032 *ppv
= &(sl
->lpvtblw
);
1034 LocalFree((HLOCAL
)sl
);
1035 ERR("E_NOINTERFACE\n");
1036 return E_NOINTERFACE
;
1042 /**************************************************************************
1043 * IShellLinkA_QueryInterface
1045 static HRESULT WINAPI
IShellLinkA_fnQueryInterface( IShellLinkA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
1047 ICOM_THIS(IShellLinkImpl
, iface
);
1049 TRACE("(%p)->(\n\tIID:\t%s)\n",This
,debugstr_guid(riid
));
1053 if(IsEqualIID(riid
, &IID_IUnknown
) ||
1054 IsEqualIID(riid
, &IID_IShellLinkA
))
1058 else if(IsEqualIID(riid
, &IID_IShellLinkW
))
1060 *ppvObj
= (IShellLinkW
*)&(This
->lpvtblw
);
1062 else if(IsEqualIID(riid
, &IID_IPersistFile
))
1064 *ppvObj
= (IPersistFile
*)&(This
->lpvtblPersistFile
);
1066 else if(IsEqualIID(riid
, &IID_IPersistStream
))
1068 *ppvObj
= (IPersistStream
*)&(This
->lpvtblPersistStream
);
1073 IUnknown_AddRef((IUnknown
*)(*ppvObj
));
1074 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
1077 TRACE("-- Interface: E_NOINTERFACE\n");
1078 return E_NOINTERFACE
;
1080 /******************************************************************************
1081 * IShellLinkA_AddRef
1083 static ULONG WINAPI
IShellLinkA_fnAddRef(IShellLinkA
* iface
)
1085 ICOM_THIS(IShellLinkImpl
, iface
);
1087 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1089 return ++(This
->ref
);
1091 /******************************************************************************
1092 * IShellLinkA_Release
1094 static ULONG WINAPI
IShellLinkA_fnRelease(IShellLinkA
* iface
)
1096 ICOM_THIS(IShellLinkImpl
, iface
);
1098 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1101 { TRACE("-- destroying IShellLink(%p)\n",This
);
1104 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1107 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1110 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1112 if (This
->sDescription
)
1113 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1116 HeapFree(GetProcessHeap(),0,This
->sPath
);
1119 SHFree(This
->pPidl
);
1121 if (This
->lpFileStream
)
1122 IStream_Release(This
->lpFileStream
);
1126 LocalFree((HANDLE
)This
);
1132 static HRESULT WINAPI
IShellLinkA_fnGetPath(IShellLinkA
* iface
, LPSTR pszFile
,INT cchMaxPath
, WIN32_FIND_DATAA
*pfd
, DWORD fFlags
)
1134 ICOM_THIS(IShellLinkImpl
, iface
);
1136 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n",This
, pszFile
, cchMaxPath
, pfd
, fFlags
, debugstr_a(This
->sPath
));
1139 lstrcpynA(pszFile
,This
->sPath
, cchMaxPath
);
1145 static HRESULT WINAPI
IShellLinkA_fnGetIDList(IShellLinkA
* iface
, LPITEMIDLIST
* ppidl
)
1147 ICOM_THIS(IShellLinkImpl
, iface
);
1149 TRACE("(%p)->(ppidl=%p)\n",This
, ppidl
);
1151 *ppidl
= ILClone(This
->pPidl
);
1154 static HRESULT WINAPI
IShellLinkA_fnSetIDList(IShellLinkA
* iface
, LPCITEMIDLIST pidl
)
1156 ICOM_THIS(IShellLinkImpl
, iface
);
1158 TRACE("(%p)->(pidl=%p)\n",This
, pidl
);
1161 SHFree(This
->pPidl
);
1162 This
->pPidl
= ILClone (pidl
);
1165 static HRESULT WINAPI
IShellLinkA_fnGetDescription(IShellLinkA
* iface
, LPSTR pszName
,INT cchMaxName
)
1167 ICOM_THIS(IShellLinkImpl
, iface
);
1169 FIXME("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1170 lstrcpynA(pszName
,"Description, FIXME",cchMaxName
);
1173 static HRESULT WINAPI
IShellLinkA_fnSetDescription(IShellLinkA
* iface
, LPCSTR pszName
)
1175 ICOM_THIS(IShellLinkImpl
, iface
);
1177 TRACE("(%p)->(pName=%s)\n", This
, pszName
);
1179 if (This
->sDescription
)
1180 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1181 if (!(This
->sDescription
= heap_strdup(pszName
)))
1182 return E_OUTOFMEMORY
;
1186 static HRESULT WINAPI
IShellLinkA_fnGetWorkingDirectory(IShellLinkA
* iface
, LPSTR pszDir
,INT cchMaxPath
)
1188 ICOM_THIS(IShellLinkImpl
, iface
);
1190 TRACE("(%p)->(%p len=%u)\n", This
, pszDir
, cchMaxPath
);
1192 lstrcpynA( pszDir
, This
->sWorkDir
? This
->sWorkDir
: "", cchMaxPath
);
1196 static HRESULT WINAPI
IShellLinkA_fnSetWorkingDirectory(IShellLinkA
* iface
, LPCSTR pszDir
)
1198 ICOM_THIS(IShellLinkImpl
, iface
);
1200 TRACE("(%p)->(dir=%s)\n",This
, pszDir
);
1203 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1204 if (!(This
->sWorkDir
= heap_strdup(pszDir
)))
1205 return E_OUTOFMEMORY
;
1209 static HRESULT WINAPI
IShellLinkA_fnGetArguments(IShellLinkA
* iface
, LPSTR pszArgs
,INT cchMaxPath
)
1211 ICOM_THIS(IShellLinkImpl
, iface
);
1213 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1215 lstrcpynA( pszArgs
, This
->sArgs
? This
->sArgs
: "", cchMaxPath
);
1219 static HRESULT WINAPI
IShellLinkA_fnSetArguments(IShellLinkA
* iface
, LPCSTR pszArgs
)
1221 ICOM_THIS(IShellLinkImpl
, iface
);
1223 TRACE("(%p)->(args=%s)\n",This
, pszArgs
);
1226 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1227 if (!(This
->sArgs
= heap_strdup(pszArgs
)))
1228 return E_OUTOFMEMORY
;
1232 static HRESULT WINAPI
IShellLinkA_fnGetHotkey(IShellLinkA
* iface
, WORD
*pwHotkey
)
1234 ICOM_THIS(IShellLinkImpl
, iface
);
1236 TRACE("(%p)->(%p)(0x%08x)\n",This
, pwHotkey
, This
->wHotKey
);
1238 *pwHotkey
= This
->wHotKey
;
1242 static HRESULT WINAPI
IShellLinkA_fnSetHotkey(IShellLinkA
* iface
, WORD wHotkey
)
1244 ICOM_THIS(IShellLinkImpl
, iface
);
1246 TRACE("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1248 This
->wHotKey
= wHotkey
;
1252 static HRESULT WINAPI
IShellLinkA_fnGetShowCmd(IShellLinkA
* iface
, INT
*piShowCmd
)
1254 ICOM_THIS(IShellLinkImpl
, iface
);
1256 FIXME("(%p)->(%p)\n",This
, piShowCmd
);
1260 static HRESULT WINAPI
IShellLinkA_fnSetShowCmd(IShellLinkA
* iface
, INT iShowCmd
)
1262 ICOM_THIS(IShellLinkImpl
, iface
);
1264 FIXME("(%p)->(showcmd=%x)\n",This
, iShowCmd
);
1267 static HRESULT WINAPI
IShellLinkA_fnGetIconLocation(IShellLinkA
* iface
, LPSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1269 ICOM_THIS(IShellLinkImpl
, iface
);
1271 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1273 lstrcpynA( pszIconPath
, This
->sIcoPath
? This
->sIcoPath
: "", cchIconPath
);
1274 *piIcon
= This
->iIcoNdx
;
1278 static HRESULT WINAPI
IShellLinkA_fnSetIconLocation(IShellLinkA
* iface
, LPCSTR pszIconPath
,INT iIcon
)
1280 ICOM_THIS(IShellLinkImpl
, iface
);
1282 TRACE("(%p)->(path=%s iicon=%u)\n",This
, pszIconPath
, iIcon
);
1285 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1286 if (!(This
->sIcoPath
= heap_strdup(pszIconPath
)))
1287 return E_OUTOFMEMORY
;
1288 This
->iIcoNdx
= iIcon
;
1292 static HRESULT WINAPI
IShellLinkA_fnSetRelativePath(IShellLinkA
* iface
, LPCSTR pszPathRel
, DWORD dwReserved
)
1294 ICOM_THIS(IShellLinkImpl
, iface
);
1296 FIXME("(%p)->(path=%s %lx)\n",This
, pszPathRel
, dwReserved
);
1299 static HRESULT WINAPI
IShellLinkA_fnResolve(IShellLinkA
* iface
, HWND hwnd
, DWORD fFlags
)
1301 ICOM_THIS(IShellLinkImpl
, iface
);
1303 FIXME("(%p)->(hwnd=%x flags=%lx)\n",This
, hwnd
, fFlags
);
1306 static HRESULT WINAPI
IShellLinkA_fnSetPath(IShellLinkA
* iface
, LPCSTR pszFile
)
1308 ICOM_THIS(IShellLinkImpl
, iface
);
1310 TRACE("(%p)->(path=%s)\n",This
, pszFile
);
1313 HeapFree(GetProcessHeap(), 0, This
->sPath
);
1314 if (!(This
->sPath
= heap_strdup(pszFile
)))
1315 return E_OUTOFMEMORY
;
1320 /**************************************************************************
1321 * IShellLink Implementation
1324 static ICOM_VTABLE(IShellLinkA
) slvt
=
1326 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1327 IShellLinkA_fnQueryInterface
,
1328 IShellLinkA_fnAddRef
,
1329 IShellLinkA_fnRelease
,
1330 IShellLinkA_fnGetPath
,
1331 IShellLinkA_fnGetIDList
,
1332 IShellLinkA_fnSetIDList
,
1333 IShellLinkA_fnGetDescription
,
1334 IShellLinkA_fnSetDescription
,
1335 IShellLinkA_fnGetWorkingDirectory
,
1336 IShellLinkA_fnSetWorkingDirectory
,
1337 IShellLinkA_fnGetArguments
,
1338 IShellLinkA_fnSetArguments
,
1339 IShellLinkA_fnGetHotkey
,
1340 IShellLinkA_fnSetHotkey
,
1341 IShellLinkA_fnGetShowCmd
,
1342 IShellLinkA_fnSetShowCmd
,
1343 IShellLinkA_fnGetIconLocation
,
1344 IShellLinkA_fnSetIconLocation
,
1345 IShellLinkA_fnSetRelativePath
,
1346 IShellLinkA_fnResolve
,
1347 IShellLinkA_fnSetPath
1351 /**************************************************************************
1352 * IShellLinkW_fnQueryInterface
1354 static HRESULT WINAPI
IShellLinkW_fnQueryInterface(
1355 IShellLinkW
* iface
, REFIID riid
, LPVOID
*ppvObj
)
1357 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1359 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObj
);
1362 /******************************************************************************
1363 * IShellLinkW_fnAddRef
1365 static ULONG WINAPI
IShellLinkW_fnAddRef(IShellLinkW
* iface
)
1367 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1369 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1371 return IShellLinkA_AddRef((IShellLinkA
*)This
);
1373 /******************************************************************************
1374 * IShellLinkW_fnRelease
1377 static ULONG WINAPI
IShellLinkW_fnRelease(IShellLinkW
* iface
)
1379 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1381 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1383 return IShellLinkA_Release((IShellLinkA
*)This
);
1386 static HRESULT WINAPI
IShellLinkW_fnGetPath(IShellLinkW
* iface
, LPWSTR pszFile
,INT cchMaxPath
, WIN32_FIND_DATAA
*pfd
, DWORD fFlags
)
1388 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1390 FIXME("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This
, pszFile
, cchMaxPath
, pfd
, fFlags
);
1391 MultiByteToWideChar( CP_ACP
, 0, "c:\\foo.bar", -1, pszFile
, cchMaxPath
);
1395 static HRESULT WINAPI
IShellLinkW_fnGetIDList(IShellLinkW
* iface
, LPITEMIDLIST
* ppidl
)
1397 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1399 FIXME("(%p)->(ppidl=%p)\n",This
, ppidl
);
1400 *ppidl
= _ILCreateDesktop();
1404 static HRESULT WINAPI
IShellLinkW_fnSetIDList(IShellLinkW
* iface
, LPCITEMIDLIST pidl
)
1406 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1408 FIXME("(%p)->(pidl=%p)\n",This
, pidl
);
1412 static HRESULT WINAPI
IShellLinkW_fnGetDescription(IShellLinkW
* iface
, LPWSTR pszName
,INT cchMaxName
)
1414 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1416 FIXME("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1417 MultiByteToWideChar( CP_ACP
, 0, "Description, FIXME", -1, pszName
, cchMaxName
);
1421 static HRESULT WINAPI
IShellLinkW_fnSetDescription(IShellLinkW
* iface
, LPCWSTR pszName
)
1423 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1425 TRACE("(%p)->(desc=%s)\n",This
, debugstr_w(pszName
));
1427 if (This
->sDescription
)
1428 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1429 if (!(This
->sDescription
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszName
)))
1430 return E_OUTOFMEMORY
;
1435 static HRESULT WINAPI
IShellLinkW_fnGetWorkingDirectory(IShellLinkW
* iface
, LPWSTR pszDir
,INT cchMaxPath
)
1437 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1439 TRACE("(%p)->(%p len %u)\n", This
, pszDir
, cchMaxPath
);
1441 MultiByteToWideChar( CP_ACP
, 0, This
->sWorkDir
? This
->sWorkDir
: "", -1, pszDir
, cchMaxPath
);
1446 static HRESULT WINAPI
IShellLinkW_fnSetWorkingDirectory(IShellLinkW
* iface
, LPCWSTR pszDir
)
1448 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1450 TRACE("(%p)->(dir=%s)\n",This
, debugstr_w(pszDir
));
1453 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1454 if (!(This
->sWorkDir
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszDir
)))
1455 return E_OUTOFMEMORY
;
1460 static HRESULT WINAPI
IShellLinkW_fnGetArguments(IShellLinkW
* iface
, LPWSTR pszArgs
,INT cchMaxPath
)
1462 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1464 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1466 MultiByteToWideChar( CP_ACP
, 0, This
->sArgs
? This
->sArgs
: "", -1, pszArgs
, cchMaxPath
);
1471 static HRESULT WINAPI
IShellLinkW_fnSetArguments(IShellLinkW
* iface
, LPCWSTR pszArgs
)
1473 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1475 TRACE("(%p)->(args=%s)\n",This
, debugstr_w(pszArgs
));
1478 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1479 if (!(This
->sArgs
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszArgs
)))
1480 return E_OUTOFMEMORY
;
1485 static HRESULT WINAPI
IShellLinkW_fnGetHotkey(IShellLinkW
* iface
, WORD
*pwHotkey
)
1487 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1489 FIXME("(%p)->(%p)\n",This
, pwHotkey
);
1494 static HRESULT WINAPI
IShellLinkW_fnSetHotkey(IShellLinkW
* iface
, WORD wHotkey
)
1496 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1498 FIXME("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1502 static HRESULT WINAPI
IShellLinkW_fnGetShowCmd(IShellLinkW
* iface
, INT
*piShowCmd
)
1504 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1506 FIXME("(%p)->(%p)\n",This
, piShowCmd
);
1511 static HRESULT WINAPI
IShellLinkW_fnSetShowCmd(IShellLinkW
* iface
, INT iShowCmd
)
1513 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1515 FIXME("(%p)->(showcmd=%x)\n",This
, iShowCmd
);
1519 static HRESULT WINAPI
IShellLinkW_fnGetIconLocation(IShellLinkW
* iface
, LPWSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1521 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1523 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1525 MultiByteToWideChar( CP_ACP
, 0, This
->sIcoPath
? This
->sIcoPath
: "", -1, pszIconPath
, cchIconPath
);
1526 *piIcon
= This
->iIcoNdx
;
1531 static HRESULT WINAPI
IShellLinkW_fnSetIconLocation(IShellLinkW
* iface
, LPCWSTR pszIconPath
,INT iIcon
)
1533 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1535 TRACE("(%p)->(path=%s iicon=%u)\n",This
, debugstr_w(pszIconPath
), iIcon
);
1538 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1539 if (!(This
->sIcoPath
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszIconPath
)))
1540 return E_OUTOFMEMORY
;
1541 This
->iIcoNdx
= iIcon
;
1546 static HRESULT WINAPI
IShellLinkW_fnSetRelativePath(IShellLinkW
* iface
, LPCWSTR pszPathRel
, DWORD dwReserved
)
1548 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1550 FIXME("(%p)->(path=%s %lx)\n",This
, debugstr_w(pszPathRel
), dwReserved
);
1554 static HRESULT WINAPI
IShellLinkW_fnResolve(IShellLinkW
* iface
, HWND hwnd
, DWORD fFlags
)
1556 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1558 FIXME("(%p)->(hwnd=%x flags=%lx)\n",This
, hwnd
, fFlags
);
1562 static HRESULT WINAPI
IShellLinkW_fnSetPath(IShellLinkW
* iface
, LPCWSTR pszFile
)
1564 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1566 TRACE("(%p)->(path=%s)\n",This
, debugstr_w(pszFile
));
1569 HeapFree(GetProcessHeap(), 0, This
->sPath
);
1570 if (!(This
->sPath
= HEAP_strdupWtoA(GetProcessHeap(), 0, pszFile
)))
1571 return E_OUTOFMEMORY
;
1576 /**************************************************************************
1577 * IShellLinkW Implementation
1580 static ICOM_VTABLE(IShellLinkW
) slvtw
=
1582 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1583 IShellLinkW_fnQueryInterface
,
1584 IShellLinkW_fnAddRef
,
1585 IShellLinkW_fnRelease
,
1586 IShellLinkW_fnGetPath
,
1587 IShellLinkW_fnGetIDList
,
1588 IShellLinkW_fnSetIDList
,
1589 IShellLinkW_fnGetDescription
,
1590 IShellLinkW_fnSetDescription
,
1591 IShellLinkW_fnGetWorkingDirectory
,
1592 IShellLinkW_fnSetWorkingDirectory
,
1593 IShellLinkW_fnGetArguments
,
1594 IShellLinkW_fnSetArguments
,
1595 IShellLinkW_fnGetHotkey
,
1596 IShellLinkW_fnSetHotkey
,
1597 IShellLinkW_fnGetShowCmd
,
1598 IShellLinkW_fnSetShowCmd
,
1599 IShellLinkW_fnGetIconLocation
,
1600 IShellLinkW_fnSetIconLocation
,
1601 IShellLinkW_fnSetRelativePath
,
1602 IShellLinkW_fnResolve
,
1603 IShellLinkW_fnSetPath