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
21 * Nearly complete informations about the binary formats
22 * of .lnk files available at http://www.wotsit.org
37 #ifdef HAVE_SYS_WAIT_H
38 # include <sys/wait.h>
40 #include "wine/debug.h"
41 #include "wine/port.h"
51 #include "undocshell.h"
54 #include "shell32_main.h"
58 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
60 /* link file formats */
62 /* flag1: lnk elements: simple link has 0x0B */
65 #define SCF_DESCRIPTION 4
66 #define SCF_RELATIVE 8
67 #define SCF_WORKDIR 0x10
69 #define SCF_CUSTOMICON 0x40
70 #define SCF_UNICODE 0x80
74 typedef struct _LINK_HEADER
76 DWORD dwSize
; /* 0x00 size of the header - 0x4c */
77 GUID MagicGuid
; /* 0x04 is CLSID_ShellLink */
78 DWORD dwFlags
; /* 0x14 describes elements following */
79 DWORD dwFileAttr
; /* 0x18 attributes of the target file */
80 FILETIME Time1
; /* 0x1c */
81 FILETIME Time2
; /* 0x24 */
82 FILETIME Time3
; /* 0x2c */
83 DWORD dwFileLength
; /* 0x34 File length */
84 DWORD nIcon
; /* 0x38 icon number */
85 DWORD fStartup
; /* 0x3c startup type */
86 DWORD wHotKey
; /* 0x40 hotkey */
87 DWORD Unknown5
; /* 0x44 */
88 DWORD Unknown6
; /* 0x48 */
89 } LINK_HEADER
, * PLINK_HEADER
;
91 #define SHLINK_LOCAL 0
92 #define SHLINK_REMOTE 1
94 typedef struct _LOCATION_INFO
100 DWORD dwLocalPathOfs
;
101 DWORD dwNetworkVolTableOfs
;
102 DWORD dwFinalPathOfs
;
105 typedef struct _LOCAL_VOLUME_INFO
115 static ICOM_VTABLE(IShellLinkA
) slvt
;
116 static ICOM_VTABLE(IShellLinkW
) slvtw
;
117 static ICOM_VTABLE(IPersistFile
) pfvt
;
118 static ICOM_VTABLE(IPersistStream
) psvt
;
120 /* IShellLink Implementation */
124 ICOM_VFIELD(IShellLinkA
);
127 ICOM_VTABLE(IShellLinkW
)* lpvtblw
;
128 ICOM_VTABLE(IPersistFile
)* lpvtblPersistFile
;
129 ICOM_VTABLE(IPersistStream
)* lpvtblPersistStream
;
131 /* data structures according to the informations in the link */
148 #define _IShellLinkW_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblw)))
149 #define _ICOM_THIS_From_IShellLinkW(class, name) class* This = (class*)(((char*)name)-_IShellLinkW_Offset)
151 #define _IPersistFile_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistFile)))
152 #define _ICOM_THIS_From_IPersistFile(class, name) class* This = (class*)(((char*)name)-_IPersistFile_Offset)
154 #define _IPersistStream_Offset ((int)(&(((IShellLinkImpl*)0)->lpvtblPersistStream)))
155 #define _ICOM_THIS_From_IPersistStream(class, name) class* This = (class*)(((char*)name)-_IPersistStream_Offset)
156 #define _IPersistStream_From_ICOM_THIS(class, name) class* StreamThis = (class*)(((char*)name)+_IPersistStream_Offset)
159 /* strdup on the process heap */
160 inline static LPWSTR
HEAP_strdupAtoW( HANDLE heap
, DWORD flags
, LPCSTR str
)
162 INT len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
163 LPWSTR p
= HeapAlloc( heap
, flags
, len
*sizeof (WCHAR
) );
166 MultiByteToWideChar( CP_ACP
, 0, str
, -1, p
, len
);
171 /**************************************************************************
172 * IPersistFile_QueryInterface
174 static HRESULT WINAPI
IPersistFile_fnQueryInterface(
179 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
181 TRACE("(%p)\n",This
);
183 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObj
);
186 /******************************************************************************
187 * IPersistFile_AddRef
189 static ULONG WINAPI
IPersistFile_fnAddRef(IPersistFile
* iface
)
191 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
193 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
195 return IShellLinkA_AddRef((IShellLinkA
*)This
);
197 /******************************************************************************
198 * IPersistFile_Release
200 static ULONG WINAPI
IPersistFile_fnRelease(IPersistFile
* iface
)
202 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
204 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
206 return IShellLinkA_Release((IShellLinkA
*)This
);
209 static HRESULT WINAPI
IPersistFile_fnGetClassID(IPersistFile
* iface
, CLSID
*pClassID
)
211 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
212 FIXME("(%p)\n",This
);
215 static HRESULT WINAPI
IPersistFile_fnIsDirty(IPersistFile
* iface
)
217 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
218 FIXME("(%p)\n",This
);
221 static HRESULT WINAPI
IPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
223 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
224 _IPersistStream_From_ICOM_THIS(IPersistStream
, This
);
228 TRACE("(%p, %s)\n",This
, debugstr_w(pszFileName
));
230 r
= CreateStreamOnFile(pszFileName
, dwMode
, &stm
);
233 r
= IPersistStream_Load(StreamThis
, stm
);
234 IStream_Release( stm
);
240 static BOOL
StartLinkProcessor( LPCOLESTR szLink
)
242 const WCHAR szFormat
[] = {'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',
243 ' ','-','r',' ','"','%','s','"',0 };
247 PROCESS_INFORMATION pi
;
249 len
= sizeof(szFormat
) + lstrlenW( szLink
) * sizeof(WCHAR
);
250 buffer
= HeapAlloc( GetProcessHeap(), 0, len
);
254 wsprintfW( buffer
, szFormat
, szLink
);
256 TRACE("starting %s\n",debugstr_w(buffer
));
258 memset(&si
, 0, sizeof(si
));
260 if (!CreateProcessW( NULL
, buffer
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
)) return FALSE
;
262 /* wait for a while to throttle the creation of linker processes */
263 if( WAIT_OBJECT_0
!= WaitForSingleObject( pi
.hProcess
, 10000 ) )
264 WARN("Timed out waiting for shell linker\n");
266 CloseHandle( pi
.hProcess
);
267 CloseHandle( pi
.hThread
);
272 static HRESULT WINAPI
IPersistFile_fnSave(IPersistFile
* iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
274 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
275 _IPersistStream_From_ICOM_THIS(IPersistStream
, This
);
279 TRACE("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
281 if (!pszFileName
|| !This
->sPath
)
282 return ERROR_UNKNOWN
;
284 r
= CreateStreamOnFile(pszFileName
, STGM_READWRITE
| STGM_CREATE
, &stm
);
287 r
= IPersistStream_Save(StreamThis
, stm
, FALSE
);
288 IStream_Release( stm
);
291 StartLinkProcessor( pszFileName
);
294 DeleteFileW( pszFileName
);
295 WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName
) );
302 static HRESULT WINAPI
IPersistFile_fnSaveCompleted(IPersistFile
* iface
, LPCOLESTR pszFileName
)
304 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
305 FIXME("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
308 static HRESULT WINAPI
IPersistFile_fnGetCurFile(IPersistFile
* iface
, LPOLESTR
*ppszFileName
)
310 _ICOM_THIS_From_IPersistFile(IShellLinkImpl
, iface
);
311 FIXME("(%p)\n",This
);
315 static ICOM_VTABLE(IPersistFile
) pfvt
=
317 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
318 IPersistFile_fnQueryInterface
,
319 IPersistFile_fnAddRef
,
320 IPersistFile_fnRelease
,
321 IPersistFile_fnGetClassID
,
322 IPersistFile_fnIsDirty
,
325 IPersistFile_fnSaveCompleted
,
326 IPersistFile_fnGetCurFile
329 /************************************************************************
330 * IPersistStream_QueryInterface
332 static HRESULT WINAPI
IPersistStream_fnQueryInterface(
333 IPersistStream
* iface
,
337 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
339 TRACE("(%p)\n",This
);
341 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvoid
);
344 /************************************************************************
345 * IPersistStream_Release
347 static ULONG WINAPI
IPersistStream_fnRelease(
348 IPersistStream
* iface
)
350 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
352 TRACE("(%p)\n",This
);
354 return IShellLinkA_Release((IShellLinkA
*)This
);
357 /************************************************************************
358 * IPersistStream_AddRef
360 static ULONG WINAPI
IPersistStream_fnAddRef(
361 IPersistStream
* iface
)
363 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
365 TRACE("(%p)\n",This
);
367 return IShellLinkA_AddRef((IShellLinkA
*)This
);
370 /************************************************************************
371 * IPersistStream_GetClassID
374 static HRESULT WINAPI
IPersistStream_fnGetClassID(
375 IPersistStream
* iface
,
378 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
380 TRACE("(%p)\n", This
);
385 /* memcpy(pClassID, &CLSID_???, sizeof(CLSID_???)); */
390 /************************************************************************
391 * IPersistStream_IsDirty (IPersistStream)
393 static HRESULT WINAPI
IPersistStream_fnIsDirty(
394 IPersistStream
* iface
)
396 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
398 TRACE("(%p)\n", This
);
404 static HRESULT
Stream_LoadString( IStream
* stm
, BOOL unicode
, LPWSTR
*pstr
)
415 r
= IStream_Read(stm
, &len
, sizeof(len
), &count
);
416 if ( FAILED (r
) || ( count
!= sizeof(len
) ) )
420 len
*= sizeof (WCHAR
);
422 TRACE("reading %d\n", len
);
423 temp
= HeapAlloc(GetProcessHeap(), 0, len
+sizeof(WCHAR
));
425 return E_OUTOFMEMORY
;
427 r
= IStream_Read(stm
, temp
, len
, &count
);
428 if( FAILED (r
) || ( count
!= len
) )
430 HeapFree( GetProcessHeap(), 0, temp
);
434 TRACE("read %s\n", debugstr_an(temp
,len
));
436 /* convert to unicode if necessary */
439 count
= MultiByteToWideChar( CP_ACP
, 0, (LPSTR
) temp
, len
, NULL
, 0 );
440 str
= HeapAlloc( GetProcessHeap(), 0, (count
+1)*sizeof (WCHAR
) );
442 MultiByteToWideChar( CP_ACP
, 0, (LPSTR
) temp
, len
, str
, count
);
443 HeapFree( GetProcessHeap(), 0, temp
);
457 static HRESULT
Stream_LoadLocation( IStream
* stm
)
466 r
= IStream_Read( stm
, &size
, sizeof(size
), &count
);
469 if( count
!= sizeof(loc
->dwTotalSize
) )
472 loc
= HeapAlloc( GetProcessHeap(), 0, size
);
474 return E_OUTOFMEMORY
;
476 r
= IStream_Read( stm
, &loc
->dwHeaderSize
, size
-sizeof(size
), &count
);
479 if( count
!= (size
- sizeof(size
)) )
484 loc
->dwTotalSize
= size
;
486 TRACE("Read %ld bytes\n",count
);
488 /* FIXME: do something useful with it */
489 HeapFree( GetProcessHeap(), 0, loc
);
493 HeapFree( GetProcessHeap(), 0, loc
);
497 /************************************************************************
498 * IPersistStream_Load (IPersistStream)
500 static HRESULT WINAPI
IPersistStream_fnLoad(
501 IPersistStream
* iface
,
507 WCHAR sTemp
[MAX_PATH
];
510 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
512 TRACE("(%p)(%p)\n", This
, stm
);
515 return STG_E_INVALIDPOINTER
;
518 r
= IStream_Read(stm
, &hdr
, sizeof(hdr
), &dwBytesRead
);
522 if( dwBytesRead
!= sizeof(hdr
))
524 if( hdr
.dwSize
!= sizeof(hdr
))
526 if( !IsEqualIID(&hdr
.MagicGuid
, &CLSID_ShellLink
) )
529 /* if( hdr.dwFlags & SCF_PIDL ) */ /* FIXME: seems to always have a PIDL */
531 r
= ILLoadFromStream( stm
, &This
->pPidl
);
535 This
->wHotKey
= hdr
.wHotKey
;
536 This
->iIcoNdx
= hdr
.nIcon
;
537 FileTimeToSystemTime (&hdr
.Time1
, &This
->time1
);
538 FileTimeToSystemTime (&hdr
.Time2
, &This
->time2
);
539 FileTimeToSystemTime (&hdr
.Time3
, &This
->time3
);
541 GetDateFormatW(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&This
->time1
, NULL
, sTemp
, 256);
542 TRACE("-- time1: %s\n", debugstr_w(sTemp
) );
543 GetDateFormatW(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&This
->time2
, NULL
, sTemp
, 256);
544 TRACE("-- time1: %s\n", debugstr_w(sTemp
) );
545 GetDateFormatW(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&This
->time3
, NULL
, sTemp
, 256);
546 TRACE("-- time1: %s\n", debugstr_w(sTemp
) );
549 if( hdr
.dwFlags
& SCF_NORMAL
)
550 r
= Stream_LoadLocation( stm
);
553 unicode
= hdr
.dwFlags
& SCF_UNICODE
;
554 if( hdr
.dwFlags
& SCF_DESCRIPTION
)
556 r
= Stream_LoadString( stm
, unicode
, &This
->sDescription
);
557 TRACE("Description -> %s\n",debugstr_w(This
->sDescription
));
562 if( hdr
.dwFlags
& SCF_RELATIVE
)
564 r
= Stream_LoadString( stm
, unicode
, &This
->sPathRel
);
565 TRACE("Relative Path-> %s\n",debugstr_w(This
->sPathRel
));
570 if( hdr
.dwFlags
& SCF_WORKDIR
)
572 r
= Stream_LoadString( stm
, unicode
, &This
->sWorkDir
);
573 TRACE("Working Dir -> %s\n",debugstr_w(This
->sWorkDir
));
578 if( hdr
.dwFlags
& SCF_ARGS
)
580 r
= Stream_LoadString( stm
, unicode
, &This
->sArgs
);
581 TRACE("Working Dir -> %s\n",debugstr_w(This
->sArgs
));
586 if( hdr
.dwFlags
& SCF_CUSTOMICON
)
588 r
= Stream_LoadString( stm
, unicode
, &This
->sIcoPath
);
589 TRACE("Icon file -> %s\n",debugstr_w(This
->sIcoPath
));
603 /************************************************************************
606 * Helper function for IPersistStream_Save. Writes a unicode string
607 * with terminating nul byte to a stream, preceded by the its length.
609 static HRESULT
Stream_WriteString( IStream
* stm
, LPCWSTR str
)
611 USHORT len
= lstrlenW( str
) + 1;
615 r
= IStream_Write( stm
, &len
, sizeof(len
), &count
);
619 len
*= sizeof(WCHAR
);
621 r
= IStream_Write( stm
, str
, len
, &count
);
628 static HRESULT
Stream_WriteLocationInfo( IStream
* stm
, LPCWSTR filename
)
633 FIXME("writing empty location info\n");
635 memset( &loc
, 0, sizeof(loc
) );
636 loc
.dwTotalSize
= sizeof(loc
) - sizeof(loc
.dwTotalSize
);
638 /* FIXME: fill this in */
640 return IStream_Write( stm
, &loc
, loc
.dwTotalSize
, &count
);
643 /************************************************************************
644 * IPersistStream_Save (IPersistStream)
646 * FIXME: makes assumptions about byte order
648 static HRESULT WINAPI
IPersistStream_fnSave(
649 IPersistStream
* iface
,
657 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
659 TRACE("(%p) %p %x\n", This
, stm
, fClearDirty
);
661 /* if there's no PIDL, generate one */
666 This
->pPidl
= ILCreateFromPathW( This
->sPath
);
669 memset(&header
, 0, sizeof(header
));
670 header
.dwSize
= sizeof(header
);
671 memcpy(&header
.MagicGuid
, &CLSID_ShellLink
, sizeof(header
.MagicGuid
) );
673 header
.wHotKey
= This
->wHotKey
;
674 header
.nIcon
= This
->iIcoNdx
;
675 header
.dwFlags
= SCF_UNICODE
; /* strings are in unicode */
676 header
.dwFlags
|= SCF_NORMAL
; /* how do we determine this ? */
678 header
.dwFlags
|= SCF_PIDL
;
679 if( This
->sDescription
)
680 header
.dwFlags
|= SCF_DESCRIPTION
;
682 header
.dwFlags
|= SCF_WORKDIR
;
684 header
.dwFlags
|= SCF_ARGS
;
686 header
.dwFlags
|= SCF_CUSTOMICON
;
688 SystemTimeToFileTime ( &This
->time1
, &header
.Time1
);
689 SystemTimeToFileTime ( &This
->time2
, &header
.Time2
);
690 SystemTimeToFileTime ( &This
->time3
, &header
.Time3
);
692 /* write the Shortcut header */
693 r
= IStream_Write( stm
, &header
, sizeof(header
), &count
);
696 ERR("Write failed at %d\n",__LINE__
);
700 TRACE("Writing pidl \n");
702 /* write the PIDL to the shortcut */
705 r
= ILSaveToStream( stm
, This
->pPidl
);
708 ERR("Failed to write PIDL at %d\n",__LINE__
);
713 TRACE("Path = %s\n", debugstr_w(This
->sPath
));
716 Stream_WriteLocationInfo( stm
, This
->sPath
);
718 TRACE("Description = %s\n", debugstr_w(This
->sDescription
));
719 if( This
->sDescription
)
720 r
= Stream_WriteString( stm
, This
->sDescription
);
723 r
= Stream_WriteString( stm
, This
->sPathRel
);
726 r
= Stream_WriteString( stm
, This
->sWorkDir
);
729 r
= Stream_WriteString( stm
, This
->sArgs
);
732 r
= Stream_WriteString( stm
, This
->sIcoPath
);
737 /************************************************************************
738 * IPersistStream_GetSizeMax (IPersistStream)
740 static HRESULT WINAPI
IPersistStream_fnGetSizeMax(
741 IPersistStream
* iface
,
742 ULARGE_INTEGER
* pcbSize
)
744 _ICOM_THIS_From_IPersistStream(IShellLinkImpl
, iface
);
746 TRACE("(%p)\n", This
);
751 static ICOM_VTABLE(IPersistStream
) psvt
=
753 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
754 IPersistStream_fnQueryInterface
,
755 IPersistStream_fnAddRef
,
756 IPersistStream_fnRelease
,
757 IPersistStream_fnGetClassID
,
758 IPersistStream_fnIsDirty
,
759 IPersistStream_fnLoad
,
760 IPersistStream_fnSave
,
761 IPersistStream_fnGetSizeMax
764 /**************************************************************************
765 * IShellLink_Constructor
767 HRESULT WINAPI
IShellLink_Constructor (
768 IUnknown
* pUnkOuter
,
774 TRACE("unkOut=%p riid=%s\n",pUnkOuter
, debugstr_guid(riid
));
778 if(pUnkOuter
) return CLASS_E_NOAGGREGATION
;
779 sl
= (IShellLinkImpl
*) LocalAlloc(GMEM_ZEROINIT
,sizeof(IShellLinkImpl
));
780 if (!sl
) return E_OUTOFMEMORY
;
784 sl
->lpvtblw
= &slvtw
;
785 sl
->lpvtblPersistFile
= &pfvt
;
786 sl
->lpvtblPersistStream
= &psvt
;
787 sl
->iShowCmd
= SW_SHOWNORMAL
;
789 TRACE("(%p)->()\n",sl
);
791 if (IsEqualIID(riid
, &IID_IUnknown
) ||
792 IsEqualIID(riid
, &IID_IShellLinkA
))
794 else if (IsEqualIID(riid
, &IID_IShellLinkW
))
795 *ppv
= &(sl
->lpvtblw
);
797 LocalFree((HLOCAL
)sl
);
798 ERR("E_NOINTERFACE\n");
799 return E_NOINTERFACE
;
806 static BOOL
SHELL_ExistsFileW(LPCWSTR path
)
808 HANDLE hfile
= CreateFileW(path
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, NULL
);
810 if (hfile
!= INVALID_HANDLE_VALUE
) {
817 /**************************************************************************
818 * SHELL_ShellLink_UpdatePath
819 * update absolute path in sPath using relative path in sPathRel
821 static HRESULT
SHELL_ShellLink_UpdatePath(LPWSTR sPathRel
, LPCWSTR path
, LPCWSTR sWorkDir
, LPWSTR
* psPath
)
823 if (!path
|| !psPath
)
826 if (!*psPath
&& sPathRel
) {
827 WCHAR buffer
[2*MAX_PATH
], abs_path
[2*MAX_PATH
];
829 /* first try if [directory of link file] + [relative path] finds an existing file */
831 LPWSTR last_slash
= NULL
;
832 LPWSTR dest
= buffer
;
835 /* copy path without file name to buffer */
837 if (*src
=='/' || *src
=='\\')
843 lstrcpyW(last_slash
? last_slash
+1: buffer
, sPathRel
);
847 if (SHELL_ExistsFileW(buffer
)) {
848 if (!GetFullPathNameW(buffer
, MAX_PATH
, abs_path
, &final
))
849 lstrcpyW(abs_path
, buffer
);
851 /* try if [working directory] + [relative path] finds an existing file */
853 lstrcpyW(buffer
, sWorkDir
);
854 lstrcpyW(PathAddBackslashW(buffer
), sPathRel
);
856 if (SHELL_ExistsFileW(buffer
))
857 if (!GetFullPathNameW(buffer
, MAX_PATH
, abs_path
, &final
))
858 lstrcpyW(abs_path
, buffer
);
862 /* FIXME: This is even not enough - not all shell links can be resolved using this algorithm. */
864 lstrcpyW(abs_path
, sPathRel
);
866 *psPath
= HeapAlloc(GetProcessHeap(), 0, (lstrlenW(abs_path
)+1)*sizeof(WCHAR
));
868 return E_OUTOFMEMORY
;
870 lstrcpyW(*psPath
, abs_path
);
876 /**************************************************************************
877 * IShellLink_ConstructFromFile
879 HRESULT WINAPI
IShellLink_ConstructFromFile (
888 HRESULT hr
= IShellLink_Constructor(NULL
, riid
, (LPVOID
*)&psl
);
895 hr
= IShellLinkW_QueryInterface(psl
, &IID_IPersistFile
, (LPVOID
*)&ppf
);
898 WCHAR path
[MAX_PATH
];
900 if (SHGetPathFromIDListW(pidl
, path
)) {
901 hr
= IPersistFile_Load(ppf
, path
, 0);
904 *ppv
= (IUnknown
*) psl
;
907 The following code is here, not in IPersistStream_fnLoad() because
908 to be able to convert the relative path into the absolute path,
909 we need to know the path of the shell link file.
911 if (IsEqualIID(riid
, &IID_IShellLinkW
)) {
912 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, psl
);
914 hr
= SHELL_ShellLink_UpdatePath(This
->sPathRel
, path
, This
->sWorkDir
, &This
->sPath
);
916 ICOM_THIS(IShellLinkImpl
, psl
);
918 hr
= SHELL_ShellLink_UpdatePath(This
->sPathRel
, path
, This
->sWorkDir
, &This
->sPath
);
923 IPersistFile_Release(ppf
);
927 IShellLinkW_Release(psl
);
933 /**************************************************************************
934 * IShellLinkA_QueryInterface
936 static HRESULT WINAPI
IShellLinkA_fnQueryInterface( IShellLinkA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
938 ICOM_THIS(IShellLinkImpl
, iface
);
940 TRACE("(%p)->(\n\tIID:\t%s)\n",This
,debugstr_guid(riid
));
944 if(IsEqualIID(riid
, &IID_IUnknown
) ||
945 IsEqualIID(riid
, &IID_IShellLinkA
))
949 else if(IsEqualIID(riid
, &IID_IShellLinkW
))
951 *ppvObj
= (IShellLinkW
*)&(This
->lpvtblw
);
953 else if(IsEqualIID(riid
, &IID_IPersistFile
))
955 *ppvObj
= (IPersistFile
*)&(This
->lpvtblPersistFile
);
957 else if(IsEqualIID(riid
, &IID_IPersistStream
))
959 *ppvObj
= (IPersistStream
*)&(This
->lpvtblPersistStream
);
964 IUnknown_AddRef((IUnknown
*)(*ppvObj
));
965 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
968 TRACE("-- Interface: E_NOINTERFACE\n");
969 return E_NOINTERFACE
;
971 /******************************************************************************
974 static ULONG WINAPI
IShellLinkA_fnAddRef(IShellLinkA
* iface
)
976 ICOM_THIS(IShellLinkImpl
, iface
);
978 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
980 return ++(This
->ref
);
982 /******************************************************************************
983 * IShellLinkA_Release
985 static ULONG WINAPI
IShellLinkA_fnRelease(IShellLinkA
* iface
)
987 ICOM_THIS(IShellLinkImpl
, iface
);
989 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
994 TRACE("-- destroying IShellLink(%p)\n",This
);
997 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1000 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1003 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1005 if (This
->sDescription
)
1006 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1009 HeapFree(GetProcessHeap(),0,This
->sPath
);
1012 ILFree(This
->pPidl
);
1014 LocalFree((HANDLE
)This
);
1019 static HRESULT WINAPI
IShellLinkA_fnGetPath(IShellLinkA
* iface
, LPSTR pszFile
,
1020 INT cchMaxPath
, WIN32_FIND_DATAA
*pfd
, DWORD fFlags
)
1022 ICOM_THIS(IShellLinkImpl
, iface
);
1024 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n",
1025 This
, pszFile
, cchMaxPath
, pfd
, fFlags
, debugstr_w(This
->sPath
));
1030 WideCharToMultiByte( CP_ACP
, 0, This
->sPath
, -1,
1031 pszFile
, cchMaxPath
, NULL
, NULL
);
1036 static HRESULT WINAPI
IShellLinkA_fnGetIDList(IShellLinkA
* iface
, LPITEMIDLIST
* ppidl
)
1038 ICOM_THIS(IShellLinkImpl
, iface
);
1040 TRACE("(%p)->(ppidl=%p)\n",This
, ppidl
);
1042 *ppidl
= ILClone(This
->pPidl
);
1047 static HRESULT WINAPI
IShellLinkA_fnSetIDList(IShellLinkA
* iface
, LPCITEMIDLIST pidl
)
1049 ICOM_THIS(IShellLinkImpl
, iface
);
1051 TRACE("(%p)->(pidl=%p)\n",This
, pidl
);
1054 ILFree(This
->pPidl
);
1055 This
->pPidl
= ILClone (pidl
);
1060 static HRESULT WINAPI
IShellLinkA_fnGetDescription(IShellLinkA
* iface
, LPSTR pszName
,INT cchMaxName
)
1062 ICOM_THIS(IShellLinkImpl
, iface
);
1064 TRACE("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1068 if( This
->sDescription
)
1069 WideCharToMultiByte( CP_ACP
, 0, This
->sDescription
, -1,
1070 pszName
, cchMaxName
, NULL
, NULL
);
1074 static HRESULT WINAPI
IShellLinkA_fnSetDescription(IShellLinkA
* iface
, LPCSTR pszName
)
1076 ICOM_THIS(IShellLinkImpl
, iface
);
1078 TRACE("(%p)->(pName=%s)\n", This
, pszName
);
1080 if (This
->sDescription
)
1081 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1082 This
->sDescription
= HEAP_strdupAtoW( GetProcessHeap(), 0, pszName
);
1083 if ( !This
->sDescription
)
1084 return E_OUTOFMEMORY
;
1089 static HRESULT WINAPI
IShellLinkA_fnGetWorkingDirectory(IShellLinkA
* iface
, LPSTR pszDir
,INT cchMaxPath
)
1091 ICOM_THIS(IShellLinkImpl
, iface
);
1093 TRACE("(%p)->(%p len=%u)\n", This
, pszDir
, cchMaxPath
);
1097 if( This
->sWorkDir
)
1098 WideCharToMultiByte( CP_ACP
, 0, This
->sWorkDir
, -1,
1099 pszDir
, cchMaxPath
, NULL
, NULL
);
1104 static HRESULT WINAPI
IShellLinkA_fnSetWorkingDirectory(IShellLinkA
* iface
, LPCSTR pszDir
)
1106 ICOM_THIS(IShellLinkImpl
, iface
);
1108 TRACE("(%p)->(dir=%s)\n",This
, pszDir
);
1111 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1112 This
->sWorkDir
= HEAP_strdupAtoW( GetProcessHeap(), 0, pszDir
);
1113 if ( !This
->sWorkDir
)
1114 return E_OUTOFMEMORY
;
1119 static HRESULT WINAPI
IShellLinkA_fnGetArguments(IShellLinkA
* iface
, LPSTR pszArgs
,INT cchMaxPath
)
1121 ICOM_THIS(IShellLinkImpl
, iface
);
1123 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1128 WideCharToMultiByte( CP_ACP
, 0, This
->sArgs
, -1,
1129 pszArgs
, cchMaxPath
, NULL
, NULL
);
1134 static HRESULT WINAPI
IShellLinkA_fnSetArguments(IShellLinkA
* iface
, LPCSTR pszArgs
)
1136 ICOM_THIS(IShellLinkImpl
, iface
);
1138 TRACE("(%p)->(args=%s)\n",This
, pszArgs
);
1141 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1142 This
->sArgs
= HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs
);
1144 return E_OUTOFMEMORY
;
1149 static HRESULT WINAPI
IShellLinkA_fnGetHotkey(IShellLinkA
* iface
, WORD
*pwHotkey
)
1151 ICOM_THIS(IShellLinkImpl
, iface
);
1153 TRACE("(%p)->(%p)(0x%08x)\n",This
, pwHotkey
, This
->wHotKey
);
1155 *pwHotkey
= This
->wHotKey
;
1160 static HRESULT WINAPI
IShellLinkA_fnSetHotkey(IShellLinkA
* iface
, WORD wHotkey
)
1162 ICOM_THIS(IShellLinkImpl
, iface
);
1164 TRACE("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1166 This
->wHotKey
= wHotkey
;
1171 static HRESULT WINAPI
IShellLinkA_fnGetShowCmd(IShellLinkA
* iface
, INT
*piShowCmd
)
1173 ICOM_THIS(IShellLinkImpl
, iface
);
1175 TRACE("(%p)->(%p)\n",This
, piShowCmd
);
1176 *piShowCmd
= This
->iShowCmd
;
1180 static HRESULT WINAPI
IShellLinkA_fnSetShowCmd(IShellLinkA
* iface
, INT iShowCmd
)
1182 ICOM_THIS(IShellLinkImpl
, iface
);
1184 TRACE("(%p) %d\n",This
, iShowCmd
);
1186 This
->iShowCmd
= iShowCmd
;
1191 static HRESULT WINAPI
IShellLinkA_fnGetIconLocation(IShellLinkA
* iface
, LPSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1193 ICOM_THIS(IShellLinkImpl
, iface
);
1195 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1199 if( This
->sIcoPath
)
1200 WideCharToMultiByte( CP_ACP
, 0, This
->sIcoPath
, -1,
1201 pszIconPath
, cchIconPath
, NULL
, NULL
);
1202 *piIcon
= This
->iIcoNdx
;
1207 static HRESULT WINAPI
IShellLinkA_fnSetIconLocation(IShellLinkA
* iface
, LPCSTR pszIconPath
,INT iIcon
)
1209 ICOM_THIS(IShellLinkImpl
, iface
);
1211 TRACE("(%p)->(path=%s iicon=%u)\n",This
, pszIconPath
, iIcon
);
1214 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1215 This
->sIcoPath
= HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath
);
1216 if ( !This
->sIcoPath
)
1217 return E_OUTOFMEMORY
;
1218 This
->iIcoNdx
= iIcon
;
1223 static HRESULT WINAPI
IShellLinkA_fnSetRelativePath(IShellLinkA
* iface
, LPCSTR pszPathRel
, DWORD dwReserved
)
1225 ICOM_THIS(IShellLinkImpl
, iface
);
1227 FIXME("(%p)->(path=%s %lx)\n",This
, pszPathRel
, dwReserved
);
1230 HeapFree(GetProcessHeap(), 0, This
->sPathRel
);
1231 This
->sPathRel
= HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel
);
1236 static HRESULT WINAPI
IShellLinkA_fnResolve(IShellLinkA
* iface
, HWND hwnd
, DWORD fFlags
)
1238 ICOM_THIS(IShellLinkImpl
, iface
);
1240 FIXME("(%p)->(hwnd=%p flags=%lx)\n",This
, hwnd
, fFlags
);
1244 static HRESULT WINAPI
IShellLinkA_fnSetPath(IShellLinkA
* iface
, LPCSTR pszFile
)
1246 ICOM_THIS(IShellLinkImpl
, iface
);
1248 TRACE("(%p)->(path=%s)\n",This
, pszFile
);
1251 HeapFree(GetProcessHeap(), 0, This
->sPath
);
1252 This
->sPath
= HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile
);
1254 return E_OUTOFMEMORY
;
1259 /**************************************************************************
1260 * IShellLink Implementation
1263 static ICOM_VTABLE(IShellLinkA
) slvt
=
1265 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1266 IShellLinkA_fnQueryInterface
,
1267 IShellLinkA_fnAddRef
,
1268 IShellLinkA_fnRelease
,
1269 IShellLinkA_fnGetPath
,
1270 IShellLinkA_fnGetIDList
,
1271 IShellLinkA_fnSetIDList
,
1272 IShellLinkA_fnGetDescription
,
1273 IShellLinkA_fnSetDescription
,
1274 IShellLinkA_fnGetWorkingDirectory
,
1275 IShellLinkA_fnSetWorkingDirectory
,
1276 IShellLinkA_fnGetArguments
,
1277 IShellLinkA_fnSetArguments
,
1278 IShellLinkA_fnGetHotkey
,
1279 IShellLinkA_fnSetHotkey
,
1280 IShellLinkA_fnGetShowCmd
,
1281 IShellLinkA_fnSetShowCmd
,
1282 IShellLinkA_fnGetIconLocation
,
1283 IShellLinkA_fnSetIconLocation
,
1284 IShellLinkA_fnSetRelativePath
,
1285 IShellLinkA_fnResolve
,
1286 IShellLinkA_fnSetPath
1290 /**************************************************************************
1291 * IShellLinkW_fnQueryInterface
1293 static HRESULT WINAPI
IShellLinkW_fnQueryInterface(
1294 IShellLinkW
* iface
, REFIID riid
, LPVOID
*ppvObj
)
1296 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1298 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObj
);
1301 /******************************************************************************
1302 * IShellLinkW_fnAddRef
1304 static ULONG WINAPI
IShellLinkW_fnAddRef(IShellLinkW
* iface
)
1306 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1308 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1310 return IShellLinkA_AddRef((IShellLinkA
*)This
);
1312 /******************************************************************************
1313 * IShellLinkW_fnRelease
1316 static ULONG WINAPI
IShellLinkW_fnRelease(IShellLinkW
* iface
)
1318 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1320 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1322 return IShellLinkA_Release((IShellLinkA
*)This
);
1325 static HRESULT WINAPI
IShellLinkW_fnGetPath(IShellLinkW
* iface
, LPWSTR pszFile
,INT cchMaxPath
, WIN32_FIND_DATAW
*pfd
, DWORD fFlags
)
1327 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1329 FIXME("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This
, pszFile
, cchMaxPath
, pfd
, fFlags
);
1333 lstrcpynW( pszFile
, This
->sPath
, cchMaxPath
);
1338 static HRESULT WINAPI
IShellLinkW_fnGetIDList(IShellLinkW
* iface
, LPITEMIDLIST
* ppidl
)
1340 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1342 TRACE("(%p)->(ppidl=%p)\n",This
, ppidl
);
1345 *ppidl
= ILClone( This
->pPidl
);
1352 static HRESULT WINAPI
IShellLinkW_fnSetIDList(IShellLinkW
* iface
, LPCITEMIDLIST pidl
)
1354 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1356 TRACE("(%p)->(pidl=%p)\n",This
, pidl
);
1359 ILFree( This
->pPidl
);
1360 This
->pPidl
= ILClone( pidl
);
1367 static HRESULT WINAPI
IShellLinkW_fnGetDescription(IShellLinkW
* iface
, LPWSTR pszName
,INT cchMaxName
)
1369 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1371 TRACE("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1375 if( This
->sDescription
)
1376 lstrcpynW( pszName
, This
->sDescription
, cchMaxName
);
1381 static HRESULT WINAPI
IShellLinkW_fnSetDescription(IShellLinkW
* iface
, LPCWSTR pszName
)
1383 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1385 TRACE("(%p)->(desc=%s)\n",This
, debugstr_w(pszName
));
1387 if (This
->sDescription
)
1388 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1389 This
->sDescription
= HeapAlloc( GetProcessHeap(), 0,
1390 (lstrlenW( pszName
)+1)*sizeof(WCHAR
) );
1391 if ( !This
->sDescription
)
1392 return E_OUTOFMEMORY
;
1393 lstrcpyW( This
->sDescription
, pszName
);
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
);
1406 if( This
->sWorkDir
)
1407 lstrcpynW( pszDir
, This
->sWorkDir
, cchMaxPath
);
1412 static HRESULT WINAPI
IShellLinkW_fnSetWorkingDirectory(IShellLinkW
* iface
, LPCWSTR pszDir
)
1414 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1416 TRACE("(%p)->(dir=%s)\n",This
, debugstr_w(pszDir
));
1419 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1420 This
->sWorkDir
= HeapAlloc( GetProcessHeap(), 0,
1421 (lstrlenW( pszDir
)+1)*sizeof (WCHAR
) );
1422 if ( !This
->sWorkDir
)
1423 return E_OUTOFMEMORY
;
1424 lstrcpyW( This
->sWorkDir
, pszDir
);
1429 static HRESULT WINAPI
IShellLinkW_fnGetArguments(IShellLinkW
* iface
, LPWSTR pszArgs
,INT cchMaxPath
)
1431 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1433 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1438 lstrcpynW( pszArgs
, This
->sArgs
, cchMaxPath
);
1443 static HRESULT WINAPI
IShellLinkW_fnSetArguments(IShellLinkW
* iface
, LPCWSTR pszArgs
)
1445 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1447 TRACE("(%p)->(args=%s)\n",This
, debugstr_w(pszArgs
));
1450 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1451 This
->sArgs
= HeapAlloc( GetProcessHeap(), 0,
1452 (lstrlenW( pszArgs
)+1)*sizeof (WCHAR
) );
1454 return E_OUTOFMEMORY
;
1455 lstrcpyW( This
->sArgs
, pszArgs
);
1460 static HRESULT WINAPI
IShellLinkW_fnGetHotkey(IShellLinkW
* iface
, WORD
*pwHotkey
)
1462 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1464 TRACE("(%p)->(%p)\n",This
, pwHotkey
);
1466 *pwHotkey
=This
->wHotKey
;
1471 static HRESULT WINAPI
IShellLinkW_fnSetHotkey(IShellLinkW
* iface
, WORD wHotkey
)
1473 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1475 TRACE("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1477 This
->wHotKey
= wHotkey
;
1482 static HRESULT WINAPI
IShellLinkW_fnGetShowCmd(IShellLinkW
* iface
, INT
*piShowCmd
)
1484 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1486 TRACE("(%p)->(%p)\n",This
, piShowCmd
);
1488 *piShowCmd
= This
->iShowCmd
;
1493 static HRESULT WINAPI
IShellLinkW_fnSetShowCmd(IShellLinkW
* iface
, INT iShowCmd
)
1495 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1497 This
->iShowCmd
= iShowCmd
;
1502 static HRESULT WINAPI
IShellLinkW_fnGetIconLocation(IShellLinkW
* iface
, LPWSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1504 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1506 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1510 if( This
->sIcoPath
)
1511 lstrcpynW( pszIconPath
, This
->sIcoPath
, cchIconPath
);
1512 *piIcon
= This
->iIcoNdx
;
1517 static HRESULT WINAPI
IShellLinkW_fnSetIconLocation(IShellLinkW
* iface
, LPCWSTR pszIconPath
,INT iIcon
)
1519 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1521 TRACE("(%p)->(path=%s iicon=%u)\n",This
, debugstr_w(pszIconPath
), iIcon
);
1524 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1525 This
->sIcoPath
= HeapAlloc( GetProcessHeap(), 0,
1526 (lstrlenW( pszIconPath
)+1)*sizeof (WCHAR
) );
1527 if ( !This
->sIcoPath
)
1528 return E_OUTOFMEMORY
;
1529 lstrcpyW( This
->sIcoPath
, pszIconPath
);
1531 This
->iIcoNdx
= iIcon
;
1536 static HRESULT WINAPI
IShellLinkW_fnSetRelativePath(IShellLinkW
* iface
, LPCWSTR pszPathRel
, DWORD dwReserved
)
1538 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1540 TRACE("(%p)->(path=%s %lx)\n",This
, debugstr_w(pszPathRel
), dwReserved
);
1543 HeapFree(GetProcessHeap(), 0, This
->sPathRel
);
1544 This
->sPathRel
= HeapAlloc( GetProcessHeap(), 0,
1545 (lstrlenW( pszPathRel
)+1) * sizeof (WCHAR
) );
1546 if ( !This
->sPathRel
)
1547 return E_OUTOFMEMORY
;
1548 lstrcpyW( This
->sPathRel
, pszPathRel
);
1553 static HRESULT WINAPI
IShellLinkW_fnResolve(IShellLinkW
* iface
, HWND hwnd
, DWORD fFlags
)
1555 _ICOM_THIS_From_IShellLinkW(IShellLinkImpl
, iface
);
1557 FIXME("(%p)->(hwnd=%p 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 This
->sPath
= HeapAlloc( GetProcessHeap(), 0,
1571 (lstrlenW( pszFile
)+1) * sizeof (WCHAR
) );
1573 return E_OUTOFMEMORY
;
1574 lstrcpyW( This
->sPath
, pszFile
);
1579 /**************************************************************************
1580 * IShellLinkW Implementation
1583 static ICOM_VTABLE(IShellLinkW
) slvtw
=
1585 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1586 IShellLinkW_fnQueryInterface
,
1587 IShellLinkW_fnAddRef
,
1588 IShellLinkW_fnRelease
,
1589 IShellLinkW_fnGetPath
,
1590 IShellLinkW_fnGetIDList
,
1591 IShellLinkW_fnSetIDList
,
1592 IShellLinkW_fnGetDescription
,
1593 IShellLinkW_fnSetDescription
,
1594 IShellLinkW_fnGetWorkingDirectory
,
1595 IShellLinkW_fnSetWorkingDirectory
,
1596 IShellLinkW_fnGetArguments
,
1597 IShellLinkW_fnSetArguments
,
1598 IShellLinkW_fnGetHotkey
,
1599 IShellLinkW_fnSetHotkey
,
1600 IShellLinkW_fnGetShowCmd
,
1601 IShellLinkW_fnSetShowCmd
,
1602 IShellLinkW_fnGetIconLocation
,
1603 IShellLinkW_fnSetIconLocation
,
1604 IShellLinkW_fnSetRelativePath
,
1605 IShellLinkW_fnResolve
,
1606 IShellLinkW_fnSetPath