3 * Copyright 1997 Marcus Meissner
4 * Copyright 1998 Juergen Schmied
5 * Copyright 2005 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * Nearly complete information about the binary formats
23 * of .lnk files available at http://www.wotsit.org
25 * You can use winedump to examine the contents of a link file:
28 * MSI advertised shortcuts are totally undocumented. They provide an
29 * icon for a program that is not yet installed, and invoke MSI to
30 * install the program when the shortcut is clicked on. They are
31 * created by passing a special string to SetPath, and the information
32 * in that string is parsed an stored.
37 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
39 /* link file formats */
43 typedef struct _LINK_HEADER
45 DWORD dwSize
; /* 0x00 size of the header - 0x4c */
46 GUID MagicGuid
; /* 0x04 is CLSID_ShellLink */
47 DWORD dwFlags
; /* 0x14 describes elements following */
48 DWORD dwFileAttr
; /* 0x18 attributes of the target file */
49 FILETIME Time1
; /* 0x1c */
50 FILETIME Time2
; /* 0x24 */
51 FILETIME Time3
; /* 0x2c */
52 DWORD dwFileLength
; /* 0x34 File length */
53 DWORD nIcon
; /* 0x38 icon number */
54 DWORD fStartup
; /* 0x3c startup type */
55 DWORD wHotKey
; /* 0x40 hotkey */
56 DWORD Unknown5
; /* 0x44 */
57 DWORD Unknown6
; /* 0x48 */
58 } LINK_HEADER
, * PLINK_HEADER
;
60 #define SHLINK_LOCAL 0
61 #define SHLINK_REMOTE 1
62 #define MAX_PROPERTY_SHEET_PAGE 32
64 typedef struct _LOCATION_INFO
71 DWORD dwNetworkVolTableOfs
;
75 typedef struct _LOCAL_VOLUME_INFO
83 typedef struct volume_info_t
87 WCHAR label
[12]; /* assume 8.3 */
92 static const IShellLinkAVtbl slvt
;
93 static const IShellLinkWVtbl slvtw
;
94 static const IPersistFileVtbl pfvt
;
95 static const IPersistStreamVtbl psvt
;
96 static const IShellLinkDataListVtbl dlvt
;
97 static const IShellExtInitVtbl eivt
;
98 static const IContextMenuVtbl cmvt
;
99 static const IObjectWithSiteVtbl owsvt
;
100 static const IShellPropSheetExtVtbl pse
;
102 /* IShellLink Implementation */
106 const IShellLinkAVtbl
*lpVtbl
;
107 const IShellLinkWVtbl
*lpvtblw
;
108 const IPersistFileVtbl
*lpvtblPersistFile
;
109 const IPersistStreamVtbl
*lpvtblPersistStream
;
110 const IShellLinkDataListVtbl
*lpvtblShellLinkDataList
;
111 const IShellExtInitVtbl
*lpvtblShellExtInit
;
112 const IContextMenuVtbl
*lpvtblContextMenu
;
113 const IObjectWithSiteVtbl
*lpvtblObjectWithSite
;
114 const IShellPropSheetExtVtbl
* lpvtblPropSheetExt
;
118 /* data structures according to the information in the link */
140 INT iIdOpen
; /* id of the "Open" entry in the context menu */
142 } IShellLinkImpl
, *LPIShellLinkImpl
;
144 static LPIShellLinkImpl __inline
impl_from_IShellLinkW( IShellLinkW
*iface
)
146 return (IShellLinkImpl
*)((char*)iface
- FIELD_OFFSET(IShellLinkImpl
, lpvtblw
));
149 static LPIShellLinkImpl __inline
impl_from_IPersistFile( IPersistFile
*iface
)
151 return (IShellLinkImpl
*)((char*)iface
- FIELD_OFFSET(IShellLinkImpl
, lpvtblPersistFile
));
154 static LPIShellLinkImpl __inline
impl_from_IPersistStream( IPersistStream
*iface
)
156 return (IShellLinkImpl
*)((char*)iface
- FIELD_OFFSET(IShellLinkImpl
, lpvtblPersistStream
));
159 static LPIShellLinkImpl __inline
impl_from_IShellLinkDataList( IShellLinkDataList
*iface
)
161 return (IShellLinkImpl
*)((char*)iface
- FIELD_OFFSET(IShellLinkImpl
, lpvtblShellLinkDataList
));
164 static LPIShellLinkImpl __inline
impl_from_IShellExtInit( IShellExtInit
*iface
)
166 return (IShellLinkImpl
*)((char*)iface
- FIELD_OFFSET(IShellLinkImpl
, lpvtblShellExtInit
));
169 static LPIShellLinkImpl __inline
impl_from_IContextMenu( IContextMenu
*iface
)
171 return (IShellLinkImpl
*)((char*)iface
- FIELD_OFFSET(IShellLinkImpl
, lpvtblContextMenu
));
174 static LPIShellLinkImpl __inline
impl_from_IObjectWithSite( IObjectWithSite
*iface
)
176 return (IShellLinkImpl
*)((char*)iface
- FIELD_OFFSET(IShellLinkImpl
, lpvtblObjectWithSite
));
179 static LPIShellLinkImpl __inline
impl_from_IShellPropSheetExt( IShellPropSheetExt
*iface
)
181 return (IShellLinkImpl
*)((char*)iface
- FIELD_OFFSET(IShellLinkImpl
, lpvtblPropSheetExt
));
185 static HRESULT
ShellLink_UpdatePath(LPCWSTR sPathRel
, LPCWSTR path
, LPCWSTR sWorkDir
, LPWSTR
* psPath
);
187 /* strdup on the process heap */
188 static LPWSTR __inline
HEAP_strdupAtoW( HANDLE heap
, DWORD flags
, LPCSTR str
)
191 INT len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
192 LPWSTR p
= HeapAlloc( heap
, flags
, len
*sizeof (WCHAR
) );
195 MultiByteToWideChar( CP_ACP
, 0, str
, -1, p
, len
);
199 static LPWSTR __inline
strdupW( LPCWSTR src
)
202 if (!src
) return NULL
;
203 dest
= HeapAlloc( GetProcessHeap(), 0, (wcslen(src
)+1)*sizeof(WCHAR
) );
209 /**************************************************************************
210 * ShellLink::QueryInterface implementation
212 static HRESULT
ShellLink_QueryInterface( IShellLinkImpl
*This
, REFIID riid
, LPVOID
*ppvObj
)
214 TRACE("(%p)->(\n\tIID:\t%s)\n",This
,debugstr_guid(riid
));
218 if(IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IShellLinkA
))
222 else if(IsEqualIID(riid
, &IID_IShellLinkW
))
224 *ppvObj
= &(This
->lpvtblw
);
226 else if(IsEqualIID(riid
, &IID_IPersistFile
))
228 *ppvObj
= &(This
->lpvtblPersistFile
);
230 else if(IsEqualIID(riid
, &IID_IPersistStream
))
232 *ppvObj
= &(This
->lpvtblPersistStream
);
234 else if(IsEqualIID(riid
, &IID_IShellLinkDataList
))
236 *ppvObj
= &(This
->lpvtblShellLinkDataList
);
238 else if(IsEqualIID(riid
, &IID_IShellExtInit
))
240 *ppvObj
= &(This
->lpvtblShellExtInit
);
242 else if(IsEqualIID(riid
, &IID_IContextMenu
))
244 *ppvObj
= &(This
->lpvtblContextMenu
);
246 else if(IsEqualIID(riid
, &IID_IObjectWithSite
))
248 *ppvObj
= &(This
->lpvtblObjectWithSite
);
250 else if(IsEqualIID(riid
, &IID_IShellPropSheetExt
))
252 *ppvObj
= &(This
->lpvtblPropSheetExt
);
257 IUnknown_AddRef((IUnknown
*)(*ppvObj
));
258 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
261 ERR("-- Interface: E_NOINTERFACE\n");
262 return E_NOINTERFACE
;
265 /**************************************************************************
266 * ShellLink::AddRef implementation
268 static ULONG
ShellLink_AddRef( IShellLinkImpl
*This
)
270 ULONG refCount
= InterlockedIncrement(&This
->ref
);
272 TRACE("(%p)->(count=%u)\n", This
, refCount
- 1);
277 /**************************************************************************
278 * ShellLink::Release implementation
280 static ULONG
ShellLink_Release( IShellLinkImpl
*This
)
282 ULONG refCount
= InterlockedDecrement(&This
->ref
);
284 TRACE("(%p)->(count=%u)\n", This
, refCount
+ 1);
289 TRACE("-- destroying IShellLink(%p)\n",This
);
291 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
292 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
293 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
294 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
295 HeapFree(GetProcessHeap(),0,This
->sPath
);
296 HeapFree(GetProcessHeap(),0,This
->sLinkPath
);
299 IUnknown_Release( This
->site
);
309 static HRESULT
ShellLink_GetClassID( IShellLinkImpl
*This
, CLSID
*pclsid
)
311 TRACE("%p %p\n", This
, pclsid
);
313 *pclsid
= CLSID_ShellLink
;
317 /**************************************************************************
318 * IPersistFile_QueryInterface
320 static HRESULT WINAPI
IPersistFile_fnQueryInterface(
325 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
326 return ShellLink_QueryInterface( This
, riid
, ppvObj
);
329 /******************************************************************************
330 * IPersistFile_AddRef
332 static ULONG WINAPI
IPersistFile_fnAddRef(IPersistFile
* iface
)
334 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
335 return ShellLink_AddRef( This
);
338 /******************************************************************************
339 * IPersistFile_Release
341 static ULONG WINAPI
IPersistFile_fnRelease(IPersistFile
* iface
)
343 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
344 return IShellLinkA_Release((IShellLinkA
*)This
);
347 static HRESULT WINAPI
IPersistFile_fnGetClassID(IPersistFile
* iface
, CLSID
*pClassID
)
349 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
350 return ShellLink_GetClassID( This
, pClassID
);
353 static HRESULT WINAPI
IPersistFile_fnIsDirty(IPersistFile
* iface
)
355 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
357 TRACE("(%p)\n",This
);
365 static HRESULT WINAPI
IPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
367 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
368 IPersistStream
*StreamThis
= (IPersistStream
*)&This
->lpvtblPersistStream
;
372 TRACE("(%p, %s, %x)\n",This
, debugstr_w(pszFileName
), dwMode
);
375 dwMode
= STGM_READ
| STGM_SHARE_DENY_WRITE
;
376 r
= SHCreateStreamOnFileW(pszFileName
, dwMode
, &stm
);
379 HeapFree(GetProcessHeap(), 0, This
->sLinkPath
);
380 This
->sLinkPath
= strdupW(pszFileName
);
381 r
= IPersistStream_Load(StreamThis
, stm
);
382 ShellLink_UpdatePath(This
->sPathRel
, pszFileName
, This
->sWorkDir
, &This
->sPath
);
383 IStream_Release( stm
);
384 This
->bDirty
= FALSE
;
386 TRACE("-- returning hr %08x\n", r
);
390 static BOOL
StartLinkProcessor( LPCOLESTR szLink
)
392 static const WCHAR szFormat
[] = {
393 'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',
394 ' ','-','w',' ','"','%','s','"',0 };
398 PROCESS_INFORMATION pi
;
401 len
= sizeof(szFormat
) + wcslen( szLink
) * sizeof(WCHAR
);
402 buffer
= HeapAlloc( GetProcessHeap(), 0, len
);
406 swprintf( buffer
, szFormat
, szLink
);
408 TRACE("starting %s\n",debugstr_w(buffer
));
410 memset(&si
, 0, sizeof(si
));
413 ret
= CreateProcessW( NULL
, buffer
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
415 HeapFree( GetProcessHeap(), 0, buffer
);
419 CloseHandle( pi
.hProcess
);
420 CloseHandle( pi
.hThread
);
426 static HRESULT WINAPI
IPersistFile_fnSave(IPersistFile
* iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
428 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
429 IPersistStream
*StreamThis
= (IPersistStream
*)&This
->lpvtblPersistStream
;
433 TRACE("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
438 r
= SHCreateStreamOnFileW( pszFileName
, STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
, &stm
);
441 r
= IPersistStream_Save(StreamThis
, stm
, FALSE
);
442 IStream_Release( stm
);
446 if ( This
->sCurFile
)
448 HeapFree(GetProcessHeap(), 0, This
->sCurFile
);
450 This
->sCurFile
= HeapAlloc(GetProcessHeap(), 0, (wcslen(pszFileName
)+1) * sizeof(WCHAR
));
451 if ( This
->sCurFile
)
453 wcscpy(This
->sCurFile
, pszFileName
);
456 StartLinkProcessor( pszFileName
);
458 This
->bDirty
= FALSE
;
462 DeleteFileW( pszFileName
);
463 WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName
) );
470 static HRESULT WINAPI
IPersistFile_fnSaveCompleted(IPersistFile
* iface
, LPCOLESTR pszFileName
)
472 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
473 FIXME("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
477 static HRESULT WINAPI
IPersistFile_fnGetCurFile(IPersistFile
* iface
, LPOLESTR
*ppszFileName
)
479 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
481 *ppszFileName
= NULL
;
483 if ( !This
->sCurFile
)
485 /* IPersistFile::GetCurFile called before IPersistFile::Save */
489 *ppszFileName
= CoTaskMemAlloc((wcslen(This
->sCurFile
)+1) * sizeof(WCHAR
));
493 return E_OUTOFMEMORY
;
496 /* copy last saved filename */
497 wcscpy(*ppszFileName
, This
->sCurFile
);
502 static const IPersistFileVtbl pfvt
=
504 IPersistFile_fnQueryInterface
,
505 IPersistFile_fnAddRef
,
506 IPersistFile_fnRelease
,
507 IPersistFile_fnGetClassID
,
508 IPersistFile_fnIsDirty
,
511 IPersistFile_fnSaveCompleted
,
512 IPersistFile_fnGetCurFile
515 /************************************************************************
516 * IPersistStream_QueryInterface
518 static HRESULT WINAPI
IPersistStream_fnQueryInterface(
519 IPersistStream
* iface
,
523 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
524 return ShellLink_QueryInterface( This
, riid
, ppvObj
);
527 /************************************************************************
528 * IPersistStream_Release
530 static ULONG WINAPI
IPersistStream_fnRelease(
531 IPersistStream
* iface
)
533 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
534 return IShellLinkA_Release((IShellLinkA
*)This
);
537 /************************************************************************
538 * IPersistStream_AddRef
540 static ULONG WINAPI
IPersistStream_fnAddRef(
541 IPersistStream
* iface
)
543 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
544 return ShellLink_AddRef( This
);
547 /************************************************************************
548 * IPersistStream_GetClassID
551 static HRESULT WINAPI
IPersistStream_fnGetClassID(
552 IPersistStream
* iface
,
555 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
556 return ShellLink_GetClassID( This
, pClassID
);
559 /************************************************************************
560 * IPersistStream_IsDirty (IPersistStream)
562 static HRESULT WINAPI
IPersistStream_fnIsDirty(
563 IPersistStream
* iface
)
565 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
567 TRACE("(%p)\n", This
);
573 static HRESULT
Stream_LoadString( IStream
* stm
, BOOL unicode
, LPWSTR
*pstr
)
584 r
= IStream_Read(stm
, &len
, sizeof(len
), &count
);
585 if ( FAILED (r
) || ( count
!= sizeof(len
) ) )
589 len
*= sizeof (WCHAR
);
591 TRACE("reading %d\n", len
);
592 temp
= HeapAlloc(GetProcessHeap(), 0, len
+sizeof(WCHAR
));
594 return E_OUTOFMEMORY
;
596 r
= IStream_Read(stm
, temp
, len
, &count
);
597 if( FAILED (r
) || ( count
!= len
) )
599 HeapFree( GetProcessHeap(), 0, temp
);
603 TRACE("read %s\n", debugstr_an(temp
,len
));
605 /* convert to unicode if necessary */
608 count
= MultiByteToWideChar( CP_ACP
, 0, temp
, len
, NULL
, 0 );
609 str
= HeapAlloc( GetProcessHeap(), 0, (count
+1)*sizeof (WCHAR
) );
612 HeapFree( GetProcessHeap(), 0, temp
);
613 return E_OUTOFMEMORY
;
615 MultiByteToWideChar( CP_ACP
, 0, temp
, len
, str
, count
);
616 HeapFree( GetProcessHeap(), 0, temp
);
630 static HRESULT
Stream_ReadChunk( IStream
* stm
, LPVOID
*data
)
637 unsigned char data
[1];
642 r
= IStream_Read( stm
, &size
, sizeof(size
), &count
);
643 if( FAILED( r
) || count
!= sizeof(size
) )
646 chunk
= HeapAlloc( GetProcessHeap(), 0, size
);
648 return E_OUTOFMEMORY
;
651 r
= IStream_Read( stm
, chunk
->data
, size
- sizeof(size
), &count
);
652 if( FAILED( r
) || count
!= (size
- sizeof(size
)) )
654 HeapFree( GetProcessHeap(), 0, chunk
);
658 TRACE("Read %d bytes\n",chunk
->size
);
665 static BOOL
Stream_LoadVolume( LOCAL_VOLUME_INFO
*vol
, volume_info
*volume
)
667 const int label_sz
= sizeof volume
->label
/sizeof volume
->label
[0];
671 volume
->serial
= vol
->dwVolSerial
;
672 volume
->type
= vol
->dwType
;
674 if( !vol
->dwVolLabelOfs
)
676 if( vol
->dwSize
<= vol
->dwVolLabelOfs
)
678 len
= vol
->dwSize
- vol
->dwVolLabelOfs
;
681 label
+= vol
->dwVolLabelOfs
;
682 MultiByteToWideChar( CP_ACP
, 0, label
, len
, volume
->label
, label_sz
-1);
687 static LPWSTR
Stream_LoadPath( LPCSTR p
, DWORD maxlen
)
692 while( p
[len
] && (len
< maxlen
) )
695 wlen
= MultiByteToWideChar(CP_ACP
, 0, p
, len
, NULL
, 0);
696 path
= HeapAlloc(GetProcessHeap(), 0, (wlen
+1)*sizeof(WCHAR
));
697 MultiByteToWideChar(CP_ACP
, 0, p
, len
, path
, wlen
);
703 static HRESULT
Stream_LoadLocation( IStream
*stm
,
704 volume_info
*volume
, LPWSTR
*path
)
711 r
= Stream_ReadChunk( stm
, (LPVOID
*) &p
);
715 loc
= (LOCATION_INFO
*) p
;
716 if (loc
->dwTotalSize
< sizeof(LOCATION_INFO
))
718 HeapFree( GetProcessHeap(), 0, p
);
722 /* if there's valid local volume information, load it */
723 if( loc
->dwVolTableOfs
&&
724 ((loc
->dwVolTableOfs
+ sizeof(LOCAL_VOLUME_INFO
)) <= loc
->dwTotalSize
) )
726 LOCAL_VOLUME_INFO
*volume_info
;
728 volume_info
= (LOCAL_VOLUME_INFO
*) &p
[loc
->dwVolTableOfs
];
729 Stream_LoadVolume( volume_info
, volume
);
732 /* if there's a local path, load it */
733 n
= loc
->dwLocalPathOfs
;
734 if( n
&& (n
< loc
->dwTotalSize
) )
735 *path
= Stream_LoadPath( &p
[n
], loc
->dwTotalSize
- n
);
737 TRACE("type %d serial %08x name %s path %s\n", volume
->type
,
738 volume
->serial
, debugstr_w(volume
->label
), debugstr_w(*path
));
740 HeapFree( GetProcessHeap(), 0, p
);
745 * The format of the advertised shortcut info seems to be:
750 * 0 Length of the block (4 bytes, usually 0x314)
752 * 8 string data in ASCII
753 * 8+0x104 string data in UNICODE
755 * In the original Win32 implementation the buffers are not initialized
756 * to zero, so data trailing the string is random garbage.
758 static HRESULT
Stream_LoadAdvertiseInfo( IStream
* stm
, LPWSTR
*str
)
763 EXP_DARWIN_LINK buffer
;
767 r
= IStream_Read( stm
, &buffer
.dbh
.cbSize
, sizeof (DWORD
), &count
);
771 /* make sure that we read the size of the structure even on error */
772 size
= sizeof buffer
- sizeof (DWORD
);
773 if( buffer
.dbh
.cbSize
!= sizeof buffer
)
775 ERR("Ooops. This structure is not as expected...\n");
779 r
= IStream_Read( stm
, &buffer
.dbh
.dwSignature
, size
, &count
);
786 TRACE("magic %08x string = %s\n", buffer
.dbh
.dwSignature
, debugstr_w(buffer
.szwDarwinID
));
788 if( (buffer
.dbh
.dwSignature
&0xffff0000) != 0xa0000000 )
790 ERR("Unknown magic number %08x in advertised shortcut\n", buffer
.dbh
.dwSignature
);
794 *str
= HeapAlloc( GetProcessHeap(), 0,
795 (wcslen(buffer
.szwDarwinID
)+1) * sizeof(WCHAR
) );
796 wcscpy( *str
, buffer
.szwDarwinID
);
801 /************************************************************************
802 * IPersistStream_Load (IPersistStream)
804 static HRESULT WINAPI
IPersistStream_fnLoad(
805 IPersistStream
* iface
,
814 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
816 TRACE("%p %p\n", This
, stm
);
819 return STG_E_INVALIDPOINTER
;
822 r
= IStream_Read(stm
, &hdr
, sizeof(hdr
), &dwBytesRead
);
826 if( dwBytesRead
!= sizeof(hdr
))
828 if( hdr
.dwSize
!= sizeof(hdr
))
830 if( !IsEqualIID(&hdr
.MagicGuid
, &CLSID_ShellLink
) )
833 /* free all the old stuff */
836 memset( &This
->volume
, 0, sizeof This
->volume
);
837 HeapFree(GetProcessHeap(), 0, This
->sPath
);
839 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
840 This
->sDescription
= NULL
;
841 HeapFree(GetProcessHeap(), 0, This
->sPathRel
);
842 This
->sPathRel
= NULL
;
843 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
844 This
->sWorkDir
= NULL
;
845 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
847 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
848 This
->sIcoPath
= NULL
;
849 HeapFree(GetProcessHeap(), 0, This
->sProduct
);
850 This
->sProduct
= NULL
;
851 HeapFree(GetProcessHeap(), 0, This
->sComponent
);
852 This
->sComponent
= NULL
;
854 This
->wHotKey
= (WORD
)hdr
.wHotKey
;
855 This
->iIcoNdx
= hdr
.nIcon
;
856 FileTimeToSystemTime (&hdr
.Time1
, &This
->time1
);
857 FileTimeToSystemTime (&hdr
.Time2
, &This
->time2
);
858 FileTimeToSystemTime (&hdr
.Time3
, &This
->time3
);
861 WCHAR sTemp
[MAX_PATH
];
862 GetDateFormatW(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
, &This
->time1
,
863 NULL
, sTemp
, sizeof(sTemp
)/sizeof(*sTemp
));
864 TRACE("-- time1: %s\n", debugstr_w(sTemp
) );
865 GetDateFormatW(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
, &This
->time2
,
866 NULL
, sTemp
, sizeof(sTemp
)/sizeof(*sTemp
));
867 TRACE("-- time2: %s\n", debugstr_w(sTemp
) );
868 GetDateFormatW(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
, &This
->time3
,
869 NULL
, sTemp
, sizeof(sTemp
)/sizeof(*sTemp
));
870 TRACE("-- time3: %s\n", debugstr_w(sTemp
) );
873 /* load all the new stuff */
874 if( hdr
.dwFlags
& SLDF_HAS_ID_LIST
)
876 r
= ILLoadFromStream( stm
, &This
->pPidl
);
882 /* load the location information */
883 if( hdr
.dwFlags
& SLDF_HAS_LINK_INFO
)
884 r
= Stream_LoadLocation( stm
, &This
->volume
, &This
->sPath
);
888 unicode
= hdr
.dwFlags
& SLDF_UNICODE
;
889 if( hdr
.dwFlags
& SLDF_HAS_NAME
)
891 r
= Stream_LoadString( stm
, unicode
, &This
->sDescription
);
892 TRACE("Description -> %s\n",debugstr_w(This
->sDescription
));
897 if( hdr
.dwFlags
& SLDF_HAS_RELPATH
)
899 r
= Stream_LoadString( stm
, unicode
, &This
->sPathRel
);
900 TRACE("Relative Path-> %s\n",debugstr_w(This
->sPathRel
));
905 if( hdr
.dwFlags
& SLDF_HAS_WORKINGDIR
)
907 r
= Stream_LoadString( stm
, unicode
, &This
->sWorkDir
);
908 TRACE("Working Dir -> %s\n",debugstr_w(This
->sWorkDir
));
913 if( hdr
.dwFlags
& SLDF_HAS_ARGS
)
915 r
= Stream_LoadString( stm
, unicode
, &This
->sArgs
);
916 TRACE("Working Dir -> %s\n",debugstr_w(This
->sArgs
));
921 if( hdr
.dwFlags
& SLDF_HAS_ICONLOCATION
)
923 r
= Stream_LoadString( stm
, unicode
, &This
->sIcoPath
);
924 TRACE("Icon file -> %s\n",debugstr_w(This
->sIcoPath
));
929 #if (NTDDI_VERSION < NTDDI_LONGHORN)
930 if( hdr
.dwFlags
& SLDF_HAS_LOGO3ID
)
932 r
= Stream_LoadAdvertiseInfo( stm
, &This
->sProduct
);
933 TRACE("Product -> %s\n",debugstr_w(This
->sProduct
));
939 if( hdr
.dwFlags
& SLDF_HAS_DARWINID
)
941 r
= Stream_LoadAdvertiseInfo( stm
, &This
->sComponent
);
942 TRACE("Component -> %s\n",debugstr_w(This
->sComponent
));
944 if( hdr
.dwFlags
& SLDF_RUNAS_USER
)
950 This
->bRunAs
= FALSE
;
956 r
= IStream_Read(stm
, &zero
, sizeof zero
, &dwBytesRead
);
957 if( FAILED( r
) || zero
|| dwBytesRead
!= sizeof zero
)
958 ERR("Last word was not zero\n");
969 /************************************************************************
972 * Helper function for IPersistStream_Save. Writes a unicode string
973 * with terminating nul byte to a stream, preceded by the its length.
975 static HRESULT
Stream_WriteString( IStream
* stm
, LPCWSTR str
)
977 USHORT len
= wcslen( str
) + 1;
981 r
= IStream_Write( stm
, &len
, sizeof(len
), &count
);
985 len
*= sizeof(WCHAR
);
987 r
= IStream_Write( stm
, str
, len
, &count
);
994 /************************************************************************
995 * Stream_WriteLocationInfo
997 * Writes the location info to a stream
999 * FIXME: One day we might want to write the network volume information
1000 * and the final path.
1001 * Figure out how Windows deals with unicode paths here.
1003 static HRESULT
Stream_WriteLocationInfo( IStream
* stm
, LPCWSTR path
,
1004 volume_info
*volume
)
1006 DWORD total_size
, path_size
, volume_info_size
, label_size
, final_path_size
;
1007 LOCAL_VOLUME_INFO
*vol
;
1009 LPSTR szLabel
, szPath
, szFinalPath
;
1013 TRACE("%p %s %p\n", stm
, debugstr_w(path
), volume
);
1015 /* figure out the size of everything */
1016 label_size
= WideCharToMultiByte( CP_ACP
, 0, volume
->label
, -1,
1017 NULL
, 0, NULL
, NULL
);
1018 path_size
= WideCharToMultiByte( CP_ACP
, 0, path
, -1,
1019 NULL
, 0, NULL
, NULL
);
1020 volume_info_size
= sizeof *vol
+ label_size
;
1021 final_path_size
= 1;
1022 total_size
= sizeof *loc
+ volume_info_size
+ path_size
+ final_path_size
;
1024 /* create pointers to everything */
1025 loc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, total_size
);
1026 vol
= (LOCAL_VOLUME_INFO
*) &loc
[1];
1027 szLabel
= (LPSTR
) &vol
[1];
1028 szPath
= &szLabel
[label_size
];
1029 szFinalPath
= &szPath
[path_size
];
1031 /* fill in the location information header */
1032 loc
->dwTotalSize
= total_size
;
1033 loc
->dwHeaderSize
= sizeof (*loc
);
1035 loc
->dwVolTableOfs
= sizeof (*loc
);
1036 loc
->dwLocalPathOfs
= sizeof (*loc
) + volume_info_size
;
1037 loc
->dwNetworkVolTableOfs
= 0;
1038 loc
->dwFinalPathOfs
= sizeof (*loc
) + volume_info_size
+ path_size
;
1040 /* fill in the volume information */
1041 vol
->dwSize
= volume_info_size
;
1042 vol
->dwType
= volume
->type
;
1043 vol
->dwVolSerial
= volume
->serial
;
1044 vol
->dwVolLabelOfs
= sizeof (*vol
);
1046 /* copy in the strings */
1047 WideCharToMultiByte( CP_ACP
, 0, volume
->label
, -1,
1048 szLabel
, label_size
, NULL
, NULL
);
1049 WideCharToMultiByte( CP_ACP
, 0, path
, -1,
1050 szPath
, path_size
, NULL
, NULL
);
1053 hr
= IStream_Write( stm
, loc
, total_size
, &count
);
1054 HeapFree(GetProcessHeap(), 0, loc
);
1059 static EXP_DARWIN_LINK
* shelllink_build_darwinid( LPCWSTR string
, DWORD magic
)
1061 EXP_DARWIN_LINK
*buffer
;
1063 buffer
= LocalAlloc( LMEM_ZEROINIT
, sizeof *buffer
);
1064 buffer
->dbh
.cbSize
= sizeof *buffer
;
1065 buffer
->dbh
.dwSignature
= magic
;
1066 lstrcpynW( buffer
->szwDarwinID
, string
, MAX_PATH
);
1067 WideCharToMultiByte(CP_ACP
, 0, string
, -1, buffer
->szDarwinID
, MAX_PATH
, NULL
, NULL
);
1072 static HRESULT
Stream_WriteAdvertiseInfo( IStream
* stm
, LPCWSTR string
, DWORD magic
)
1074 EXP_DARWIN_LINK
*buffer
;
1079 buffer
= shelllink_build_darwinid( string
, magic
);
1081 return IStream_Write( stm
, buffer
, buffer
->dbh
.cbSize
, &count
);
1084 /************************************************************************
1085 * IPersistStream_Save (IPersistStream)
1087 * FIXME: makes assumptions about byte order
1089 static HRESULT WINAPI
IPersistStream_fnSave(
1090 IPersistStream
* iface
,
1099 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
1101 TRACE("%p %p %x\n", This
, stm
, fClearDirty
);
1103 memset(&header
, 0, sizeof(header
));
1104 header
.dwSize
= sizeof(header
);
1105 header
.fStartup
= This
->iShowCmd
;
1106 header
.MagicGuid
= CLSID_ShellLink
;
1108 header
.wHotKey
= This
->wHotKey
;
1109 header
.nIcon
= This
->iIcoNdx
;
1110 header
.dwFlags
= SLDF_UNICODE
; /* strings are in unicode */
1112 header
.dwFlags
|= SLDF_HAS_ID_LIST
;
1114 header
.dwFlags
|= SLDF_HAS_LINK_INFO
;
1115 if( This
->sDescription
)
1116 header
.dwFlags
|= SLDF_HAS_NAME
;
1117 if( This
->sWorkDir
)
1118 header
.dwFlags
|= SLDF_HAS_WORKINGDIR
;
1120 header
.dwFlags
|= SLDF_HAS_ARGS
;
1121 if( This
->sIcoPath
)
1122 header
.dwFlags
|= SLDF_HAS_ICONLOCATION
;
1123 #if (NTDDI_VERSION < NTDDI_LONGHORN)
1124 if( This
->sProduct
)
1125 header
.dwFlags
|= SLDF_HAS_LOGO3ID
;
1127 if( This
->sComponent
)
1128 header
.dwFlags
|= SLDF_HAS_DARWINID
;
1130 header
.dwFlags
|= SLDF_RUNAS_USER
;
1132 SystemTimeToFileTime ( &This
->time1
, &header
.Time1
);
1133 SystemTimeToFileTime ( &This
->time2
, &header
.Time2
);
1134 SystemTimeToFileTime ( &This
->time3
, &header
.Time3
);
1136 /* write the Shortcut header */
1137 r
= IStream_Write( stm
, &header
, sizeof(header
), &count
);
1140 ERR("Write failed at %d\n",__LINE__
);
1144 TRACE("Writing pidl\n");
1146 /* write the PIDL to the shortcut */
1149 r
= ILSaveToStream( stm
, This
->pPidl
);
1152 ERR("Failed to write PIDL at %d\n",__LINE__
);
1158 Stream_WriteLocationInfo( stm
, This
->sPath
, &This
->volume
);
1160 if( This
->sDescription
)
1161 r
= Stream_WriteString( stm
, This
->sDescription
);
1163 if( This
->sPathRel
)
1164 r
= Stream_WriteString( stm
, This
->sPathRel
);
1166 if( This
->sWorkDir
)
1167 r
= Stream_WriteString( stm
, This
->sWorkDir
);
1170 r
= Stream_WriteString( stm
, This
->sArgs
);
1172 if( This
->sIcoPath
)
1173 r
= Stream_WriteString( stm
, This
->sIcoPath
);
1175 if( This
->sProduct
)
1176 r
= Stream_WriteAdvertiseInfo( stm
, This
->sProduct
, EXP_SZ_ICON_SIG
);
1178 if( This
->sComponent
)
1179 r
= Stream_WriteAdvertiseInfo( stm
, This
->sComponent
, EXP_DARWIN_ID_SIG
);
1181 /* the last field is a single zero dword */
1183 r
= IStream_Write( stm
, &zero
, sizeof zero
, &count
);
1188 /************************************************************************
1189 * IPersistStream_GetSizeMax (IPersistStream)
1191 static HRESULT WINAPI
IPersistStream_fnGetSizeMax(
1192 IPersistStream
* iface
,
1193 ULARGE_INTEGER
* pcbSize
)
1195 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
1197 TRACE("(%p)\n", This
);
1202 static const IPersistStreamVtbl psvt
=
1204 IPersistStream_fnQueryInterface
,
1205 IPersistStream_fnAddRef
,
1206 IPersistStream_fnRelease
,
1207 IPersistStream_fnGetClassID
,
1208 IPersistStream_fnIsDirty
,
1209 IPersistStream_fnLoad
,
1210 IPersistStream_fnSave
,
1211 IPersistStream_fnGetSizeMax
1214 /**************************************************************************
1215 * IShellLink_Constructor
1217 HRESULT WINAPI
IShellLink_Constructor( IUnknown
*pUnkOuter
,
1218 REFIID riid
, LPVOID
*ppv
)
1220 IShellLinkImpl
* sl
;
1223 TRACE("unkOut=%p riid=%s\n",pUnkOuter
, debugstr_guid(riid
));
1228 return CLASS_E_NOAGGREGATION
;
1229 sl
= LocalAlloc(LMEM_ZEROINIT
,sizeof(IShellLinkImpl
));
1231 return E_OUTOFMEMORY
;
1235 sl
->lpvtblw
= &slvtw
;
1236 sl
->lpvtblPersistFile
= &pfvt
;
1237 sl
->lpvtblPersistStream
= &psvt
;
1238 sl
->lpvtblShellLinkDataList
= &dlvt
;
1239 sl
->lpvtblShellExtInit
= &eivt
;
1240 sl
->lpvtblContextMenu
= &cmvt
;
1241 sl
->lpvtblObjectWithSite
= &owsvt
;
1242 sl
->lpvtblPropSheetExt
= &pse
;
1243 sl
->iShowCmd
= SW_SHOWNORMAL
;
1249 TRACE("(%p)->()\n",sl
);
1251 r
= ShellLink_QueryInterface( sl
, riid
, ppv
);
1252 ShellLink_Release( sl
);
1257 static BOOL
SHELL_ExistsFileW(LPCWSTR path
)
1259 if (INVALID_FILE_ATTRIBUTES
== GetFileAttributesW(path
))
1264 /**************************************************************************
1265 * ShellLink_UpdatePath
1266 * update absolute path in sPath using relative path in sPathRel
1268 static HRESULT
ShellLink_UpdatePath(LPCWSTR sPathRel
, LPCWSTR path
, LPCWSTR sWorkDir
, LPWSTR
* psPath
)
1270 if (!path
|| !psPath
)
1271 return E_INVALIDARG
;
1273 if (!*psPath
&& sPathRel
) {
1274 WCHAR buffer
[2*MAX_PATH
], abs_path
[2*MAX_PATH
];
1275 LPWSTR final
= NULL
;
1277 /* first try if [directory of link file] + [relative path] finds an existing file */
1279 GetFullPathNameW( path
, MAX_PATH
*2, buffer
, &final
);
1282 wcscpy(final
, sPathRel
);
1286 if (SHELL_ExistsFileW(buffer
)) {
1287 if (!GetFullPathNameW(buffer
, MAX_PATH
, abs_path
, &final
))
1288 wcscpy(abs_path
, buffer
);
1290 /* try if [working directory] + [relative path] finds an existing file */
1292 wcscpy(buffer
, sWorkDir
);
1293 wcscpy(PathAddBackslashW(buffer
), sPathRel
);
1295 if (SHELL_ExistsFileW(buffer
))
1296 if (!GetFullPathNameW(buffer
, MAX_PATH
, abs_path
, &final
))
1297 wcscpy(abs_path
, buffer
);
1301 /* FIXME: This is even not enough - not all shell links can be resolved using this algorithm. */
1303 wcscpy(abs_path
, sPathRel
);
1305 *psPath
= HeapAlloc(GetProcessHeap(), 0, (wcslen(abs_path
)+1)*sizeof(WCHAR
));
1307 return E_OUTOFMEMORY
;
1309 wcscpy(*psPath
, abs_path
);
1315 /**************************************************************************
1316 * IShellLink_ConstructFromFile
1318 HRESULT WINAPI
IShellLink_ConstructFromFile( IUnknown
* pUnkOuter
, REFIID riid
,
1319 LPCITEMIDLIST pidl
, LPVOID
* ppv
)
1323 HRESULT hr
= IShellLink_Constructor(NULL
, riid
, (LPVOID
*)&psl
);
1325 if (SUCCEEDED(hr
)) {
1330 hr
= IShellLinkW_QueryInterface(psl
, &IID_IPersistFile
, (LPVOID
*)&ppf
);
1332 if (SUCCEEDED(hr
)) {
1333 WCHAR path
[MAX_PATH
];
1335 if (SHGetPathFromIDListW(pidl
, path
))
1336 hr
= IPersistFile_Load(ppf
, path
, 0);
1343 IPersistFile_Release(ppf
);
1347 IShellLinkW_Release(psl
);
1353 /**************************************************************************
1354 * IShellLinkA_QueryInterface
1356 static HRESULT WINAPI
IShellLinkA_fnQueryInterface( IShellLinkA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
1358 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1359 return ShellLink_QueryInterface( This
, riid
, ppvObj
);
1362 /******************************************************************************
1363 * IShellLinkA_AddRef
1365 static ULONG WINAPI
IShellLinkA_fnAddRef(IShellLinkA
* iface
)
1367 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1368 return ShellLink_AddRef( This
);
1371 /******************************************************************************
1372 * IShellLinkA_Release
1374 static ULONG WINAPI
IShellLinkA_fnRelease(IShellLinkA
* iface
)
1376 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1377 return ShellLink_Release( This
);
1380 static HRESULT WINAPI
IShellLinkA_fnGetPath(IShellLinkA
* iface
, LPSTR pszFile
,
1381 INT cchMaxPath
, WIN32_FIND_DATAA
*pfd
, DWORD fFlags
)
1383 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1385 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1386 This
, pszFile
, cchMaxPath
, pfd
, fFlags
, debugstr_w(This
->sPath
));
1391 WideCharToMultiByte( CP_ACP
, 0, This
->sPath
, -1,
1392 pszFile
, cchMaxPath
, NULL
, NULL
);
1394 if (pfd
) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This
);
1399 static HRESULT WINAPI
IShellLinkA_fnGetIDList(IShellLinkA
* iface
, LPITEMIDLIST
* ppidl
)
1401 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1403 TRACE("(%p)->(ppidl=%p)\n",This
, ppidl
);
1405 return IShellLinkW_GetIDList((IShellLinkW
*)&(This
->lpvtblw
), ppidl
);
1408 static HRESULT WINAPI
IShellLinkA_fnSetIDList(IShellLinkA
* iface
, LPCITEMIDLIST pidl
)
1410 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1412 TRACE("(%p)->(pidl=%p)\n",This
, pidl
);
1415 ILFree(This
->pPidl
);
1416 This
->pPidl
= ILClone (pidl
);
1417 This
->bDirty
= TRUE
;
1422 static HRESULT WINAPI
IShellLinkA_fnGetDescription(IShellLinkA
* iface
, LPSTR pszName
,INT cchMaxName
)
1424 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1426 TRACE("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1430 if( This
->sDescription
)
1431 WideCharToMultiByte( CP_ACP
, 0, This
->sDescription
, -1,
1432 pszName
, cchMaxName
, NULL
, NULL
);
1437 static HRESULT WINAPI
IShellLinkA_fnSetDescription(IShellLinkA
* iface
, LPCSTR pszName
)
1439 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1441 TRACE("(%p)->(pName=%s)\n", This
, pszName
);
1443 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1444 This
->sDescription
= NULL
;
1447 This
->sDescription
= HEAP_strdupAtoW( GetProcessHeap(), 0, pszName
);
1448 if ( !This
->sDescription
)
1449 return E_OUTOFMEMORY
;
1451 This
->bDirty
= TRUE
;
1456 static HRESULT WINAPI
IShellLinkA_fnGetWorkingDirectory(IShellLinkA
* iface
, LPSTR pszDir
,INT cchMaxPath
)
1458 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1460 TRACE("(%p)->(%p len=%u)\n", This
, pszDir
, cchMaxPath
);
1464 if( This
->sWorkDir
)
1465 WideCharToMultiByte( CP_ACP
, 0, This
->sWorkDir
, -1,
1466 pszDir
, cchMaxPath
, NULL
, NULL
);
1471 static HRESULT WINAPI
IShellLinkA_fnSetWorkingDirectory(IShellLinkA
* iface
, LPCSTR pszDir
)
1473 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1475 TRACE("(%p)->(dir=%s)\n",This
, pszDir
);
1477 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1478 This
->sWorkDir
= NULL
;
1481 This
->sWorkDir
= HEAP_strdupAtoW( GetProcessHeap(), 0, pszDir
);
1482 if ( !This
->sWorkDir
)
1483 return E_OUTOFMEMORY
;
1485 This
->bDirty
= TRUE
;
1490 static HRESULT WINAPI
IShellLinkA_fnGetArguments(IShellLinkA
* iface
, LPSTR pszArgs
,INT cchMaxPath
)
1492 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1494 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1499 WideCharToMultiByte( CP_ACP
, 0, This
->sArgs
, -1,
1500 pszArgs
, cchMaxPath
, NULL
, NULL
);
1505 static HRESULT WINAPI
IShellLinkA_fnSetArguments(IShellLinkA
* iface
, LPCSTR pszArgs
)
1507 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1509 TRACE("(%p)->(args=%s)\n",This
, pszArgs
);
1511 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1515 This
->sArgs
= HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs
);
1517 return E_OUTOFMEMORY
;
1520 This
->bDirty
= TRUE
;
1525 static HRESULT WINAPI
IShellLinkA_fnGetHotkey(IShellLinkA
* iface
, WORD
*pwHotkey
)
1527 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1529 TRACE("(%p)->(%p)(0x%08x)\n",This
, pwHotkey
, This
->wHotKey
);
1531 *pwHotkey
= This
->wHotKey
;
1536 static HRESULT WINAPI
IShellLinkA_fnSetHotkey(IShellLinkA
* iface
, WORD wHotkey
)
1538 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1540 TRACE("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1542 This
->wHotKey
= wHotkey
;
1543 This
->bDirty
= TRUE
;
1548 static HRESULT WINAPI
IShellLinkA_fnGetShowCmd(IShellLinkA
* iface
, INT
*piShowCmd
)
1550 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1552 TRACE("(%p)->(%p)\n",This
, piShowCmd
);
1553 *piShowCmd
= This
->iShowCmd
;
1557 static HRESULT WINAPI
IShellLinkA_fnSetShowCmd(IShellLinkA
* iface
, INT iShowCmd
)
1559 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1561 TRACE("(%p) %d\n",This
, iShowCmd
);
1563 This
->iShowCmd
= iShowCmd
;
1564 This
->bDirty
= TRUE
;
1569 static HRESULT
SHELL_PidlGeticonLocationA(IShellFolder
* psf
, LPCITEMIDLIST pidl
,
1570 LPSTR pszIconPath
, int cchIconPath
, int* piIcon
)
1572 LPCITEMIDLIST pidlLast
;
1574 HRESULT hr
= SHBindToParent(pidl
, &IID_IShellFolder
, (LPVOID
*)&psf
, &pidlLast
);
1576 if (SUCCEEDED(hr
)) {
1579 hr
= IShellFolder_GetUIObjectOf(psf
, 0, 1, &pidlLast
, &IID_IExtractIconA
, NULL
, (LPVOID
*)&pei
);
1581 if (SUCCEEDED(hr
)) {
1582 hr
= IExtractIconA_GetIconLocation(pei
, 0, pszIconPath
, MAX_PATH
, piIcon
, NULL
);
1584 IExtractIconA_Release(pei
);
1587 IShellFolder_Release(psf
);
1593 static HRESULT WINAPI
IShellLinkA_fnGetIconLocation(IShellLinkA
* iface
, LPSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1595 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1597 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1600 *piIcon
= This
->iIcoNdx
;
1604 WideCharToMultiByte(CP_ACP
, 0, This
->sIcoPath
, -1, pszIconPath
, cchIconPath
, NULL
, NULL
);
1608 if (This
->pPidl
|| This
->sPath
)
1612 HRESULT hr
= SHGetDesktopFolder(&pdsk
);
1616 /* first look for an icon using the PIDL (if present) */
1618 hr
= SHELL_PidlGeticonLocationA(pdsk
, This
->pPidl
, pszIconPath
, cchIconPath
, piIcon
);
1622 /* if we couldn't find an icon yet, look for it using the file system path */
1623 if (FAILED(hr
) && This
->sPath
)
1627 hr
= IShellFolder_ParseDisplayName(pdsk
, 0, NULL
, This
->sPath
, NULL
, &pidl
, NULL
);
1629 if (SUCCEEDED(hr
)) {
1630 hr
= SHELL_PidlGeticonLocationA(pdsk
, pidl
, pszIconPath
, cchIconPath
, piIcon
);
1636 IShellFolder_Release(pdsk
);
1644 static HRESULT WINAPI
IShellLinkA_fnSetIconLocation(IShellLinkA
* iface
, LPCSTR pszIconPath
,INT iIcon
)
1646 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1648 TRACE("(%p)->(path=%s iicon=%u)\n",This
, pszIconPath
, iIcon
);
1650 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1651 This
->sIcoPath
= NULL
;
1653 if ( pszIconPath
) {
1654 This
->sIcoPath
= HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath
);
1655 if ( !This
->sIcoPath
)
1656 return E_OUTOFMEMORY
;
1659 This
->iIcoNdx
= iIcon
;
1660 This
->bDirty
= TRUE
;
1665 static HRESULT WINAPI
IShellLinkA_fnSetRelativePath(IShellLinkA
* iface
, LPCSTR pszPathRel
, DWORD dwReserved
)
1667 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1669 TRACE("(%p)->(path=%s %x)\n",This
, pszPathRel
, dwReserved
);
1671 HeapFree(GetProcessHeap(), 0, This
->sPathRel
);
1672 This
->sPathRel
= NULL
;
1675 This
->sPathRel
= HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel
);
1677 if ( !This
->sPathRel
)
1678 return E_OUTOFMEMORY
;
1681 This
->bDirty
= TRUE
;
1683 return ShellLink_UpdatePath(This
->sPathRel
, This
->sPath
, This
->sWorkDir
, &This
->sPath
);
1686 static HRESULT WINAPI
IShellLinkA_fnResolve(IShellLinkA
* iface
, HWND hwnd
, DWORD fFlags
)
1688 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1690 TRACE("(%p)->(hwnd=%p flags=%x)\n",This
, hwnd
, fFlags
);
1692 return IShellLinkW_Resolve( (IShellLinkW
*)&(This
->lpvtblw
), hwnd
, fFlags
);
1695 static HRESULT WINAPI
IShellLinkA_fnSetPath(IShellLinkA
* iface
, LPCSTR pszFile
)
1699 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1701 TRACE("(%p)->(path=%s)\n",This
, pszFile
);
1703 if (!pszFile
) return E_INVALIDARG
;
1705 str
= HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile
);
1707 return E_OUTOFMEMORY
;
1709 r
= IShellLinkW_SetPath((IShellLinkW
*)&(This
->lpvtblw
), str
);
1710 HeapFree( GetProcessHeap(), 0, str
);
1715 /**************************************************************************
1716 * IShellLink Implementation
1719 static const IShellLinkAVtbl slvt
=
1721 IShellLinkA_fnQueryInterface
,
1722 IShellLinkA_fnAddRef
,
1723 IShellLinkA_fnRelease
,
1724 IShellLinkA_fnGetPath
,
1725 IShellLinkA_fnGetIDList
,
1726 IShellLinkA_fnSetIDList
,
1727 IShellLinkA_fnGetDescription
,
1728 IShellLinkA_fnSetDescription
,
1729 IShellLinkA_fnGetWorkingDirectory
,
1730 IShellLinkA_fnSetWorkingDirectory
,
1731 IShellLinkA_fnGetArguments
,
1732 IShellLinkA_fnSetArguments
,
1733 IShellLinkA_fnGetHotkey
,
1734 IShellLinkA_fnSetHotkey
,
1735 IShellLinkA_fnGetShowCmd
,
1736 IShellLinkA_fnSetShowCmd
,
1737 IShellLinkA_fnGetIconLocation
,
1738 IShellLinkA_fnSetIconLocation
,
1739 IShellLinkA_fnSetRelativePath
,
1740 IShellLinkA_fnResolve
,
1741 IShellLinkA_fnSetPath
1745 /**************************************************************************
1746 * IShellLinkW_fnQueryInterface
1748 static HRESULT WINAPI
IShellLinkW_fnQueryInterface(
1749 IShellLinkW
* iface
, REFIID riid
, LPVOID
*ppvObj
)
1751 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1752 return ShellLink_QueryInterface( This
, riid
, ppvObj
);
1755 /******************************************************************************
1756 * IShellLinkW_fnAddRef
1758 static ULONG WINAPI
IShellLinkW_fnAddRef(IShellLinkW
* iface
)
1760 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1761 return ShellLink_AddRef( This
);
1764 /******************************************************************************
1765 * IShellLinkW_fnRelease
1767 static ULONG WINAPI
IShellLinkW_fnRelease(IShellLinkW
* iface
)
1769 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1770 return ShellLink_Release( This
);
1773 static HRESULT WINAPI
IShellLinkW_fnGetPath(IShellLinkW
* iface
, LPWSTR pszFile
,INT cchMaxPath
, WIN32_FIND_DATAW
*pfd
, DWORD fFlags
)
1775 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1777 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1778 This
, pszFile
, cchMaxPath
, pfd
, fFlags
, debugstr_w(This
->sPath
));
1780 if (This
->sComponent
|| This
->sProduct
)
1786 lstrcpynW( pszFile
, This
->sPath
, cchMaxPath
);
1788 if (pfd
) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This
);
1793 static HRESULT WINAPI
IShellLinkW_fnGetIDList(IShellLinkW
* iface
, LPITEMIDLIST
* ppidl
)
1795 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1797 TRACE("(%p)->(ppidl=%p)\n",This
, ppidl
);
1804 *ppidl
= ILClone(This
->pPidl
);
1808 static HRESULT WINAPI
IShellLinkW_fnSetIDList(IShellLinkW
* iface
, LPCITEMIDLIST pidl
)
1810 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1812 TRACE("(%p)->(pidl=%p)\n",This
, pidl
);
1815 ILFree( This
->pPidl
);
1816 This
->pPidl
= ILClone( pidl
);
1820 This
->bDirty
= TRUE
;
1825 static HRESULT WINAPI
IShellLinkW_fnGetDescription(IShellLinkW
* iface
, LPWSTR pszName
,INT cchMaxName
)
1827 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1829 TRACE("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1832 if( This
->sDescription
)
1833 lstrcpynW( pszName
, This
->sDescription
, cchMaxName
);
1838 static HRESULT WINAPI
IShellLinkW_fnSetDescription(IShellLinkW
* iface
, LPCWSTR pszName
)
1840 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1842 TRACE("(%p)->(desc=%s)\n",This
, debugstr_w(pszName
));
1844 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1845 This
->sDescription
= HeapAlloc( GetProcessHeap(), 0,
1846 (wcslen( pszName
)+1)*sizeof(WCHAR
) );
1847 if ( !This
->sDescription
)
1848 return E_OUTOFMEMORY
;
1850 wcscpy( This
->sDescription
, pszName
);
1851 This
->bDirty
= TRUE
;
1856 static HRESULT WINAPI
IShellLinkW_fnGetWorkingDirectory(IShellLinkW
* iface
, LPWSTR pszDir
,INT cchMaxPath
)
1858 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1860 TRACE("(%p)->(%p len %u)\n", This
, pszDir
, cchMaxPath
);
1864 if( This
->sWorkDir
)
1865 lstrcpynW( pszDir
, This
->sWorkDir
, cchMaxPath
);
1870 static HRESULT WINAPI
IShellLinkW_fnSetWorkingDirectory(IShellLinkW
* iface
, LPCWSTR pszDir
)
1872 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1874 TRACE("(%p)->(dir=%s)\n",This
, debugstr_w(pszDir
));
1876 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1877 This
->sWorkDir
= HeapAlloc( GetProcessHeap(), 0,
1878 (wcslen( pszDir
)+1)*sizeof (WCHAR
) );
1879 if ( !This
->sWorkDir
)
1880 return E_OUTOFMEMORY
;
1881 wcscpy( This
->sWorkDir
, pszDir
);
1882 This
->bDirty
= TRUE
;
1887 static HRESULT WINAPI
IShellLinkW_fnGetArguments(IShellLinkW
* iface
, LPWSTR pszArgs
,INT cchMaxPath
)
1889 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1891 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1896 lstrcpynW( pszArgs
, This
->sArgs
, cchMaxPath
);
1901 static HRESULT WINAPI
IShellLinkW_fnSetArguments(IShellLinkW
* iface
, LPCWSTR pszArgs
)
1903 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1905 TRACE("(%p)->(args=%s)\n",This
, debugstr_w(pszArgs
));
1907 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1908 This
->sArgs
= HeapAlloc( GetProcessHeap(), 0,
1909 (wcslen( pszArgs
)+1)*sizeof (WCHAR
) );
1911 return E_OUTOFMEMORY
;
1912 wcscpy( This
->sArgs
, pszArgs
);
1913 This
->bDirty
= TRUE
;
1918 static HRESULT WINAPI
IShellLinkW_fnGetHotkey(IShellLinkW
* iface
, WORD
*pwHotkey
)
1920 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1922 TRACE("(%p)->(%p)\n",This
, pwHotkey
);
1924 *pwHotkey
=This
->wHotKey
;
1929 static HRESULT WINAPI
IShellLinkW_fnSetHotkey(IShellLinkW
* iface
, WORD wHotkey
)
1931 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1933 TRACE("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1935 This
->wHotKey
= wHotkey
;
1936 This
->bDirty
= TRUE
;
1941 static HRESULT WINAPI
IShellLinkW_fnGetShowCmd(IShellLinkW
* iface
, INT
*piShowCmd
)
1943 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1945 TRACE("(%p)->(%p)\n",This
, piShowCmd
);
1947 *piShowCmd
= This
->iShowCmd
;
1952 static HRESULT WINAPI
IShellLinkW_fnSetShowCmd(IShellLinkW
* iface
, INT iShowCmd
)
1954 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1956 This
->iShowCmd
= iShowCmd
;
1957 This
->bDirty
= TRUE
;
1962 static HRESULT
SHELL_PidlGeticonLocationW(IShellFolder
* psf
, LPCITEMIDLIST pidl
,
1963 LPWSTR pszIconPath
, int cchIconPath
, int* piIcon
)
1965 LPCITEMIDLIST pidlLast
;
1968 HRESULT hr
= SHBindToParent(pidl
, &IID_IShellFolder
, (LPVOID
*)&psf
, &pidlLast
);
1970 if (SUCCEEDED(hr
)) {
1973 hr
= IShellFolder_GetUIObjectOf(psf
, 0, 1, &pidlLast
, &IID_IExtractIconW
, NULL
, (LPVOID
*)&pei
);
1975 if (SUCCEEDED(hr
)) {
1976 hr
= IExtractIconW_GetIconLocation(pei
, 0, pszIconPath
, MAX_PATH
, piIcon
, &wFlags
);
1978 IExtractIconW_Release(pei
);
1981 IShellFolder_Release(psf
);
1987 static HRESULT WINAPI
IShellLinkW_fnGetIconLocation(IShellLinkW
* iface
, LPWSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1989 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1991 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1994 *piIcon
= This
->iIcoNdx
;
1998 lstrcpynW(pszIconPath
, This
->sIcoPath
, cchIconPath
);
2002 if (This
->pPidl
|| This
->sPath
)
2006 HRESULT hr
= SHGetDesktopFolder(&pdsk
);
2010 /* first look for an icon using the PIDL (if present) */
2012 hr
= SHELL_PidlGeticonLocationW(pdsk
, This
->pPidl
, pszIconPath
, cchIconPath
, piIcon
);
2016 /* if we couldn't find an icon yet, look for it using the file system path */
2017 if (FAILED(hr
) && This
->sPath
)
2021 hr
= IShellFolder_ParseDisplayName(pdsk
, 0, NULL
, This
->sPath
, NULL
, &pidl
, NULL
);
2025 hr
= SHELL_PidlGeticonLocationW(pdsk
, pidl
, pszIconPath
, cchIconPath
, piIcon
);
2031 IShellFolder_Release(pdsk
);
2038 static HRESULT WINAPI
IShellLinkW_fnSetIconLocation(IShellLinkW
* iface
, LPCWSTR pszIconPath
,INT iIcon
)
2040 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
2042 TRACE("(%p)->(path=%s iicon=%u)\n",This
, debugstr_w(pszIconPath
), iIcon
);
2044 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
2045 This
->sIcoPath
= HeapAlloc( GetProcessHeap(), 0,
2046 (wcslen( pszIconPath
)+1)*sizeof (WCHAR
) );
2047 if ( !This
->sIcoPath
)
2048 return E_OUTOFMEMORY
;
2049 wcscpy( This
->sIcoPath
, pszIconPath
);
2051 This
->iIcoNdx
= iIcon
;
2052 This
->bDirty
= TRUE
;
2057 static HRESULT WINAPI
IShellLinkW_fnSetRelativePath(IShellLinkW
* iface
, LPCWSTR pszPathRel
, DWORD dwReserved
)
2059 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
2061 TRACE("(%p)->(path=%s %x)\n",This
, debugstr_w(pszPathRel
), dwReserved
);
2063 HeapFree(GetProcessHeap(), 0, This
->sPathRel
);
2064 This
->sPathRel
= HeapAlloc( GetProcessHeap(), 0,
2065 (wcslen( pszPathRel
)+1) * sizeof (WCHAR
) );
2066 if ( !This
->sPathRel
)
2067 return E_OUTOFMEMORY
;
2068 wcscpy( This
->sPathRel
, pszPathRel
);
2069 This
->bDirty
= TRUE
;
2071 return ShellLink_UpdatePath(This
->sPathRel
, This
->sPath
, This
->sWorkDir
, &This
->sPath
);
2074 static HRESULT WINAPI
IShellLinkW_fnResolve(IShellLinkW
* iface
, HWND hwnd
, DWORD fFlags
)
2079 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
2081 TRACE("(%p)->(hwnd=%p flags=%x)\n",This
, hwnd
, fFlags
);
2083 /*FIXME: use IResolveShellLink interface */
2085 if (!This
->sPath
&& This
->pPidl
) {
2086 WCHAR buffer
[MAX_PATH
];
2088 bSuccess
= SHGetPathFromIDListW(This
->pPidl
, buffer
);
2090 if (bSuccess
&& *buffer
) {
2091 This
->sPath
= HeapAlloc(GetProcessHeap(), 0, (wcslen(buffer
)+1)*sizeof(WCHAR
));
2093 return E_OUTOFMEMORY
;
2095 wcscpy(This
->sPath
, buffer
);
2097 This
->bDirty
= TRUE
;
2099 hr
= S_OK
; /* don't report an error occurred while just caching information */
2102 if (!This
->sIcoPath
&& This
->sPath
) {
2103 This
->sIcoPath
= HeapAlloc(GetProcessHeap(), 0, (wcslen(This
->sPath
)+1)*sizeof(WCHAR
));
2104 if (!This
->sIcoPath
)
2105 return E_OUTOFMEMORY
;
2107 wcscpy(This
->sIcoPath
, This
->sPath
);
2110 This
->bDirty
= TRUE
;
2116 static LPWSTR
ShellLink_GetAdvertisedArg(LPCWSTR str
)
2125 p
= wcschr( str
, ':' );
2129 ret
= HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR
)*(len
+1));
2132 memcpy( ret
, str
, sizeof(WCHAR
)*len
);
2137 static HRESULT
ShellLink_SetAdvertiseInfo(IShellLinkImpl
*This
, LPCWSTR str
)
2139 LPCWSTR szComponent
= NULL
, szProduct
= NULL
, p
;
2147 /* each segment must start with two colons */
2148 if( str
[0] != ':' || str
[1] != ':' )
2151 /* the last segment is just two colons */
2156 /* there must be a colon straight after a guid */
2157 p
= wcschr( str
, ':' );
2164 /* get the guid, and check it's validly formatted */
2165 memcpy( szGuid
, str
, sizeof(WCHAR
)*len
);
2167 r
= CLSIDFromString( szGuid
, &guid
);
2172 /* match it up to a guid that we care about */
2173 if( IsEqualGUID( &guid
, &SHELL32_AdvtShortcutComponent
) && !szComponent
)
2175 else if( IsEqualGUID( &guid
, &SHELL32_AdvtShortcutProduct
) && !szProduct
)
2180 /* skip to the next field */
2181 str
= wcschr( str
, ':' );
2186 /* we have to have a component for an advertised shortcut */
2190 This
->sComponent
= ShellLink_GetAdvertisedArg( szComponent
);
2191 This
->sProduct
= ShellLink_GetAdvertisedArg( szProduct
);
2193 TRACE("Component = %s\n", debugstr_w(This
->sComponent
));
2194 TRACE("Product = %s\n", debugstr_w(This
->sProduct
));
2199 static BOOL
ShellLink_GetVolumeInfo(LPCWSTR path
, volume_info
*volume
)
2201 const int label_sz
= sizeof volume
->label
/sizeof volume
->label
[0];
2202 WCHAR drive
[4] = { path
[0], ':', '\\', 0 };
2205 volume
->type
= GetDriveTypeW(drive
);
2206 r
= GetVolumeInformationW(drive
, volume
->label
, label_sz
,
2207 &volume
->serial
, NULL
, NULL
, NULL
, 0);
2208 TRACE("r = %d type %d serial %08x name %s\n", r
,
2209 volume
->type
, volume
->serial
, debugstr_w(volume
->label
));
2213 static HRESULT WINAPI
IShellLinkW_fnSetPath(IShellLinkW
* iface
, LPCWSTR pszFile
)
2215 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
2216 WCHAR buffer
[MAX_PATH
];
2217 LPWSTR fname
, unquoted
= NULL
;
2221 TRACE("(%p)->(path=%s)\n",This
, debugstr_w(pszFile
));
2223 if (!pszFile
) return E_INVALIDARG
;
2225 /* quotes at the ends of the string are stripped */
2226 len
= wcslen(pszFile
);
2227 if (pszFile
[0] == '"' && pszFile
[len
-1] == '"')
2229 unquoted
= strdupW(pszFile
);
2230 PathUnquoteSpacesW(unquoted
);
2234 /* any other quote marks are invalid */
2235 if (wcschr(pszFile
, '"'))
2237 HeapFree(GetProcessHeap(), 0, unquoted
);
2241 HeapFree(GetProcessHeap(), 0, This
->sPath
);
2244 HeapFree(GetProcessHeap(), 0, This
->sComponent
);
2245 This
->sComponent
= NULL
;
2248 ILFree(This
->pPidl
);
2251 if (S_OK
!= ShellLink_SetAdvertiseInfo( This
, pszFile
))
2253 if (*pszFile
== '\0')
2255 else if (!GetFullPathNameW(pszFile
, MAX_PATH
, buffer
, &fname
))
2257 else if(!PathFileExistsW(buffer
) &&
2258 !SearchPathW(NULL
, pszFile
, NULL
, MAX_PATH
, buffer
, NULL
))
2261 This
->pPidl
= SHSimpleIDListFromPathW(pszFile
);
2262 ShellLink_GetVolumeInfo(buffer
, &This
->volume
);
2264 This
->sPath
= HeapAlloc( GetProcessHeap(), 0,
2265 (wcslen( buffer
)+1) * sizeof (WCHAR
) );
2267 return E_OUTOFMEMORY
;
2269 wcscpy(This
->sPath
, buffer
);
2271 This
->bDirty
= TRUE
;
2272 HeapFree(GetProcessHeap(), 0, unquoted
);
2277 /**************************************************************************
2278 * IShellLinkW Implementation
2281 static const IShellLinkWVtbl slvtw
=
2283 IShellLinkW_fnQueryInterface
,
2284 IShellLinkW_fnAddRef
,
2285 IShellLinkW_fnRelease
,
2286 IShellLinkW_fnGetPath
,
2287 IShellLinkW_fnGetIDList
,
2288 IShellLinkW_fnSetIDList
,
2289 IShellLinkW_fnGetDescription
,
2290 IShellLinkW_fnSetDescription
,
2291 IShellLinkW_fnGetWorkingDirectory
,
2292 IShellLinkW_fnSetWorkingDirectory
,
2293 IShellLinkW_fnGetArguments
,
2294 IShellLinkW_fnSetArguments
,
2295 IShellLinkW_fnGetHotkey
,
2296 IShellLinkW_fnSetHotkey
,
2297 IShellLinkW_fnGetShowCmd
,
2298 IShellLinkW_fnSetShowCmd
,
2299 IShellLinkW_fnGetIconLocation
,
2300 IShellLinkW_fnSetIconLocation
,
2301 IShellLinkW_fnSetRelativePath
,
2302 IShellLinkW_fnResolve
,
2303 IShellLinkW_fnSetPath
2306 static HRESULT WINAPI
2307 ShellLink_DataList_QueryInterface( IShellLinkDataList
* iface
, REFIID riid
, void** ppvObject
)
2309 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2310 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObject
);
2314 ShellLink_DataList_AddRef( IShellLinkDataList
* iface
)
2316 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2317 return IShellLinkA_AddRef((IShellLinkA
*)This
);
2321 ShellLink_DataList_Release( IShellLinkDataList
* iface
)
2323 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2324 return ShellLink_Release( This
);
2327 static HRESULT WINAPI
2328 ShellLink_AddDataBlock( IShellLinkDataList
* iface
, void* pDataBlock
)
2334 static HRESULT WINAPI
2335 ShellLink_CopyDataBlock( IShellLinkDataList
* iface
, DWORD dwSig
, void** ppDataBlock
)
2337 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2338 LPVOID block
= NULL
;
2341 TRACE("%p %08x %p\n", iface
, dwSig
, ppDataBlock
);
2345 case EXP_DARWIN_ID_SIG
:
2346 if (!This
->sComponent
)
2348 block
= shelllink_build_darwinid( This
->sComponent
, dwSig
);
2351 case EXP_SZ_LINK_SIG
:
2352 case NT_CONSOLE_PROPS_SIG
:
2353 case NT_FE_CONSOLE_PROPS_SIG
:
2354 case EXP_SPECIAL_FOLDER_SIG
:
2355 case EXP_SZ_ICON_SIG
:
2356 FIXME("valid but unhandled datablock %08x\n", dwSig
);
2359 ERR("unknown datablock %08x\n", dwSig
);
2361 *ppDataBlock
= block
;
2365 static HRESULT WINAPI
2366 ShellLink_RemoveDataBlock( IShellLinkDataList
* iface
, DWORD dwSig
)
2372 static HRESULT WINAPI
2373 ShellLink_GetFlags( IShellLinkDataList
* iface
, DWORD
* pdwFlags
)
2375 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2378 FIXME("%p %p\n", This
, pdwFlags
);
2380 /* FIXME: add more */
2382 flags
|= SLDF_HAS_ARGS
;
2383 if (This
->sComponent
)
2384 flags
|= SLDF_HAS_DARWINID
;
2386 flags
|= SLDF_HAS_ICONLOCATION
;
2387 #if (NTDDI_VERSION < NTDDI_LONGHORN)
2389 flags
|= SLDF_HAS_LOGO3ID
;
2392 flags
|= SLDF_HAS_ID_LIST
;
2399 static HRESULT WINAPI
2400 ShellLink_SetFlags( IShellLinkDataList
* iface
, DWORD dwFlags
)
2406 static const IShellLinkDataListVtbl dlvt
=
2408 ShellLink_DataList_QueryInterface
,
2409 ShellLink_DataList_AddRef
,
2410 ShellLink_DataList_Release
,
2411 ShellLink_AddDataBlock
,
2412 ShellLink_CopyDataBlock
,
2413 ShellLink_RemoveDataBlock
,
2418 static HRESULT WINAPI
2419 ShellLink_ExtInit_QueryInterface( IShellExtInit
* iface
, REFIID riid
, void** ppvObject
)
2421 IShellLinkImpl
*This
= impl_from_IShellExtInit(iface
);
2422 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObject
);
2426 ShellLink_ExtInit_AddRef( IShellExtInit
* iface
)
2428 IShellLinkImpl
*This
= impl_from_IShellExtInit(iface
);
2429 return IShellLinkA_AddRef((IShellLinkA
*)This
);
2433 ShellLink_ExtInit_Release( IShellExtInit
* iface
)
2435 IShellLinkImpl
*This
= impl_from_IShellExtInit(iface
);
2436 return ShellLink_Release( This
);
2439 /**************************************************************************
2440 * ShellLink implementation of IShellExtInit::Initialize()
2442 * Loads the shelllink from the dataobject the shell is pointing to.
2444 static HRESULT WINAPI
2445 ShellLink_ExtInit_Initialize( IShellExtInit
* iface
, LPCITEMIDLIST pidlFolder
,
2446 IDataObject
*pdtobj
, HKEY hkeyProgID
)
2448 IShellLinkImpl
*This
= impl_from_IShellExtInit(iface
);
2454 TRACE("%p %p %p %p\n", This
, pidlFolder
, pdtobj
, hkeyProgID
);
2459 format
.cfFormat
= CF_HDROP
;
2461 format
.dwAspect
= DVASPECT_CONTENT
;
2463 format
.tymed
= TYMED_HGLOBAL
;
2465 if( FAILED( IDataObject_GetData( pdtobj
, &format
, &stgm
) ) )
2468 count
= DragQueryFileW( stgm
.u
.hGlobal
, -1, NULL
, 0 );
2473 count
= DragQueryFileW( stgm
.u
.hGlobal
, 0, NULL
, 0 );
2475 path
= HeapAlloc( GetProcessHeap(), 0, count
*sizeof(WCHAR
) );
2478 IPersistFile
*pf
= (IPersistFile
*) &This
->lpvtblPersistFile
;
2480 count
= DragQueryFileW( stgm
.u
.hGlobal
, 0, path
, count
);
2481 r
= IPersistFile_Load( pf
, path
, 0 );
2482 HeapFree( GetProcessHeap(), 0, path
);
2485 ReleaseStgMedium( &stgm
);
2490 static const IShellExtInitVtbl eivt
=
2492 ShellLink_ExtInit_QueryInterface
,
2493 ShellLink_ExtInit_AddRef
,
2494 ShellLink_ExtInit_Release
,
2495 ShellLink_ExtInit_Initialize
2498 static HRESULT WINAPI
2499 ShellLink_ContextMenu_QueryInterface( IContextMenu
* iface
, REFIID riid
, void** ppvObject
)
2501 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2502 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObject
);
2506 ShellLink_ContextMenu_AddRef( IContextMenu
* iface
)
2508 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2509 return IShellLinkA_AddRef((IShellLinkA
*)This
);
2513 ShellLink_ContextMenu_Release( IContextMenu
* iface
)
2515 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2516 return ShellLink_Release( This
);
2519 static HRESULT WINAPI
2520 ShellLink_QueryContextMenu( IContextMenu
* iface
, HMENU hmenu
, UINT indexMenu
,
2521 UINT idCmdFirst
, UINT idCmdLast
, UINT uFlags
)
2523 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2528 TRACE("%p %p %u %u %u %u\n", This
,
2529 hmenu
, indexMenu
, idCmdFirst
, idCmdLast
, uFlags
);
2532 return E_INVALIDARG
;
2534 if (!LoadStringW(shell32_hInstance
, IDS_OPEN_VERB
, szOpen
, sizeof(szOpen
)/sizeof(WCHAR
)))
2537 szOpen
[(sizeof(szOpen
)/sizeof(WCHAR
))-1] = L
'\0';
2539 memset( &mii
, 0, sizeof(mii
) );
2540 mii
.cbSize
= sizeof (mii
);
2541 mii
.fMask
= MIIM_TYPE
| MIIM_ID
| MIIM_STATE
;
2542 mii
.dwTypeData
= (LPWSTR
)szOpen
;
2543 mii
.cch
= wcslen( mii
.dwTypeData
);
2544 mii
.wID
= idCmdFirst
+ id
++;
2545 mii
.fState
= MFS_DEFAULT
| MFS_ENABLED
;
2546 mii
.fType
= MFT_STRING
;
2547 if (!InsertMenuItemW( hmenu
, indexMenu
, TRUE
, &mii
))
2551 return MAKE_HRESULT( SEVERITY_SUCCESS
, 0, id
);
2555 shelllink_get_msi_component_path( LPWSTR component
)
2560 r
= CommandLineFromMsiDescriptor( component
, NULL
, &sz
);
2561 if (r
!= ERROR_SUCCESS
)
2565 path
= HeapAlloc( GetProcessHeap(), 0, sz
*sizeof(WCHAR
) );
2566 r
= CommandLineFromMsiDescriptor( component
, path
, &sz
);
2567 if (r
!= ERROR_SUCCESS
)
2569 HeapFree( GetProcessHeap(), 0, path
);
2573 TRACE("returning %s\n", debugstr_w( path
) );
2578 INT_PTR CALLBACK
ExtendedShortcutProc(
2592 hDlgCtrl
= GetDlgItem(hwndDlg
, 14000);
2593 SendMessage(hDlgCtrl
, BM_SETCHECK
, BST_CHECKED
, 0);
2597 hDlgCtrl
= GetDlgItem(hwndDlg
, 14000);
2598 if (LOWORD(wParam
) == IDOK
)
2600 if ( SendMessage(hDlgCtrl
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
2601 EndDialog(hwndDlg
, 1);
2603 EndDialog(hwndDlg
, 0);
2605 else if (LOWORD(wParam
) == IDCANCEL
)
2607 EndDialog(hwndDlg
, -1);
2609 else if (LOWORD(wParam
) == 14000)
2611 if ( SendMessage(hDlgCtrl
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
2612 SendMessage(hDlgCtrl
, BM_SETCHECK
, BST_UNCHECKED
, 0);
2614 SendMessage(hDlgCtrl
, BM_SETCHECK
, BST_CHECKED
, 0);
2621 /**************************************************************************
2622 * SH_ShellLinkDlgProc
2624 * dialog proc of the shortcut property dialog
2629 SH_ShellLinkDlgProc(
2636 LPPROPSHEETPAGEW ppsp
;
2638 IShellLinkImpl
*This
;
2640 WCHAR szBuffer
[MAX_PATH
];
2645 This
= (IShellLinkImpl
*)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
2650 ppsp
= (LPPROPSHEETPAGEW
)lParam
;
2654 TRACE("ShellLink_DlgProc (WM_INITDIALOG hwnd %p lParam %p ppsplParam %x)\n",hwndDlg
, lParam
, ppsp
->lParam
);
2656 This
= (IShellLinkImpl
*)ppsp
->lParam
;
2657 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)This
);
2659 TRACE("sArgs: %S sComponent: %S sDescription: %S sIcoPath: %S sPath: %S sPathRel: %S sProduct: %S sWorkDir: %S\n", This
->sArgs
, This
->sComponent
,This
->sDescription
,
2660 This
->sIcoPath
, This
->sPath
, This
->sPathRel
, This
->sProduct
, This
->sWorkDir
);
2663 hDlgCtrl
= GetDlgItem( hwndDlg
, 14009 );
2664 if ( hDlgCtrl
!= NULL
)
2665 SendMessageW( hDlgCtrl
, WM_SETTEXT
, (WPARAM
)NULL
, (LPARAM
)This
->sPath
);
2668 hDlgCtrl
= GetDlgItem( hwndDlg
, 14011 );
2669 if ( hDlgCtrl
!= NULL
)
2670 SendMessageW( hDlgCtrl
, WM_SETTEXT
, (WPARAM
)NULL
, (LPARAM
)This
->sWorkDir
);
2673 hDlgCtrl
= GetDlgItem( hwndDlg
, 14019 );
2674 if ( hDlgCtrl
!= NULL
)
2675 SendMessageW( hDlgCtrl
, WM_SETTEXT
, (WPARAM
)NULL
, (LPARAM
)This
->sDescription
);
2678 lppsn
= (LPPSHNOTIFY
) lParam
;
2679 if ( lppsn
->hdr
.code
== PSN_APPLY
)
2681 /* set working directory */
2682 hDlgCtrl
= GetDlgItem( hwndDlg
, 14011 );
2683 SendMessageW( hDlgCtrl
, WM_GETTEXT
, (WPARAM
)MAX_PATH
, (LPARAM
)szBuffer
);
2684 IShellLinkW_fnSetWorkingDirectory((IShellLinkW
*)&This
->lpvtblw
, szBuffer
);
2685 /* set link destination */
2686 hDlgCtrl
= GetDlgItem( hwndDlg
, 14009 );
2687 SendMessageW( hDlgCtrl
, WM_GETTEXT
, (WPARAM
)MAX_PATH
, (LPARAM
)szBuffer
);
2688 if ( !SHELL_ExistsFileW(szBuffer
) )
2690 //FIXME load localized error msg
2691 MessageBoxW( hwndDlg
, L
"file not existing", szBuffer
, MB_OK
);
2692 SetWindowLongPtr( hwndDlg
, DWL_MSGRESULT
, PSNRET_INVALID_NOCHANGEPAGE
);
2695 ptr
= wcsrchr(szBuffer
, L
'.');
2696 if (ptr
&& !_wcsnicmp(ptr
, L
".lnk", 4))
2698 // FIXME load localized error msg
2699 MessageBoxW( hwndDlg
, L
"You cannot create a link to a shortcut", L
"Error", MB_ICONERROR
);
2700 SetWindowLongPtr( hwndDlg
, DWL_MSGRESULT
, PSNRET_INVALID_NOCHANGEPAGE
);
2704 IShellLinkW_fnSetPath((IShellLinkW
*)&This
->lpvtblw
, szBuffer
);
2706 TRACE("This %p sLinkPath %S\n", This
, This
->sLinkPath
);
2707 IPersistFile_fnSave( (IPersistFile
*)&This
->lpvtblPersistFile
, This
->sLinkPath
, TRUE
);
2708 SetWindowLongPtr( hwndDlg
, DWL_MSGRESULT
, PSNRET_NOERROR
);
2713 switch(LOWORD(wParam
))
2718 /// open target directory
2723 wcscpy(szBuffer
, This
->sIcoPath
);
2725 wcscpy(szBuffer
, This
->sPath
);
2727 IconIndex
= This
->iIcoNdx
;
2728 if (PickIconDlg(hwndDlg
, szBuffer
, MAX_PATH
, &IconIndex
))
2730 IShellLinkW_fnSetIconLocation((IShellLinkW
*)&This
->lpvtblw
, szBuffer
, IconIndex
);
2732 /// FIXME redraw icon
2736 result
= DialogBoxParamW(shell32_hInstance
, MAKEINTRESOURCEW(SHELL_EXTENDED_SHORTCUT_DLG
), hwndDlg
, ExtendedShortcutProc
, (LPARAM
)This
->bRunAs
);
2737 if (result
== 1 || result
== 0)
2739 if ( This
->bRunAs
!= result
)
2741 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
2744 This
->bRunAs
= result
;
2748 switch(HIWORD(wParam
))
2751 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
2761 /**************************************************************************
2762 * ShellLink_IShellPropSheetExt interface
2765 static HRESULT WINAPI
2766 ShellLink_IShellPropSheetExt_QueryInterface( IShellPropSheetExt
* iface
, REFIID riid
, void** ppvObject
)
2768 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2769 return ShellLink_QueryInterface( This
, riid
, ppvObject
);
2773 ShellLink_IShellPropSheetExt_AddRef( IShellPropSheetExt
* iface
)
2775 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2776 return ShellLink_AddRef( This
);
2780 ShellLink_IShellPropSheetExt_Release( IShellPropSheetExt
* iface
)
2782 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2783 return ShellLink_Release( This
);
2786 static HRESULT WINAPI
2787 ShellLink_IShellPropSheetExt_AddPages( IShellPropSheetExt
*iface
, LPFNADDPROPSHEETPAGE pfnAddPage
, LPARAM lParam
)
2789 HPROPSHEETPAGE hPage
;
2791 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2793 hPage
= SH_CreatePropertySheetPage("SHELL_GENERAL_SHORTCUT_DLG", SH_ShellLinkDlgProc
, (LPARAM
)This
, NULL
);
2796 ERR("failed to create property sheet page\n");
2800 bRet
= pfnAddPage(hPage
, lParam
);
2807 static HRESULT WINAPI
2808 ShellLink_IShellPropSheetExt_ReplacePages( IShellPropSheetExt
*iface
, UINT uPageID
, LPFNADDPROPSHEETPAGE pfnReplacePage
, LPARAM lParam
)
2810 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2811 TRACE("(%p) (uPageID %u, pfnReplacePage %p lParam %p\n", This
, uPageID
, pfnReplacePage
, lParam
);
2815 static const IShellPropSheetExtVtbl pse
=
2817 ShellLink_IShellPropSheetExt_QueryInterface
,
2818 ShellLink_IShellPropSheetExt_AddRef
,
2819 ShellLink_IShellPropSheetExt_Release
,
2820 ShellLink_IShellPropSheetExt_AddPages
,
2821 ShellLink_IShellPropSheetExt_ReplacePages
2824 static HRESULT WINAPI
2825 ShellLink_InvokeCommand( IContextMenu
* iface
, LPCMINVOKECOMMANDINFO lpici
)
2827 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2828 static const WCHAR szOpen
[] = { 'o','p','e','n',0 };
2829 static const WCHAR szCplOpen
[] = { 'c','p','l','o','p','e','n',0 };
2830 SHELLEXECUTEINFOW sei
;
2831 HWND hwnd
= NULL
; /* FIXME: get using interface set from IObjectWithSite */
2836 TRACE("%p %p\n", This
, lpici
);
2838 if ( lpici
->cbSize
< sizeof (CMINVOKECOMMANDINFO
) )
2839 return E_INVALIDARG
;
2841 r
= IShellLinkW_Resolve( (IShellLinkW
*)&(This
->lpvtblw
), hwnd
, 0 );
2844 TRACE("failed to resolve component with error 0x%08x", r
);
2847 if ( This
->sComponent
)
2849 path
= shelllink_get_msi_component_path( This
->sComponent
);
2854 path
= strdupW( This
->sPath
);
2856 if ( lpici
->cbSize
== sizeof (CMINVOKECOMMANDINFOEX
) &&
2857 ( lpici
->fMask
& CMIC_MASK_UNICODE
) )
2859 LPCMINVOKECOMMANDINFOEX iciex
= (LPCMINVOKECOMMANDINFOEX
) lpici
;
2863 len
+= wcslen( This
->sArgs
);
2864 if ( iciex
->lpParametersW
)
2865 len
+= wcslen( iciex
->lpParametersW
);
2867 args
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
) );
2870 wcscat( args
, This
->sArgs
);
2871 if ( iciex
->lpParametersW
)
2873 static const WCHAR space
[] = { ' ', 0 };
2874 wcscat( args
, space
);
2875 wcscat( args
, iciex
->lpParametersW
);
2878 else if (This
->sArgs
!= NULL
)
2880 args
= strdupW( This
->sArgs
);
2883 memset( &sei
, 0, sizeof sei
);
2884 sei
.cbSize
= sizeof sei
;
2885 sei
.fMask
= SEE_MASK_UNICODE
| (lpici
->fMask
& (SEE_MASK_NOASYNC
|SEE_MASK_ASYNCOK
|SEE_MASK_FLAG_NO_UI
));
2887 sei
.nShow
= This
->iShowCmd
;
2888 sei
.lpDirectory
= This
->sWorkDir
;
2889 sei
.lpParameters
= args
;
2890 sei
.lpVerb
= szOpen
;
2892 // HACK for ShellExecuteExW
2893 if (!wcsstr(This
->sPath
, L
".cpl"))
2894 sei
.lpVerb
= szOpen
;
2896 sei
.lpVerb
= szCplOpen
;
2898 if( ShellExecuteExW( &sei
) )
2903 HeapFree( GetProcessHeap(), 0, args
);
2904 HeapFree( GetProcessHeap(), 0, path
);
2909 static HRESULT WINAPI
2910 ShellLink_GetCommandString( IContextMenu
* iface
, UINT_PTR idCmd
, UINT uType
,
2911 UINT
* pwReserved
, LPSTR pszName
, UINT cchMax
)
2913 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2915 FIXME("%p %lu %u %p %p %u\n", This
,
2916 idCmd
, uType
, pwReserved
, pszName
, cchMax
);
2921 static const IContextMenuVtbl cmvt
=
2923 ShellLink_ContextMenu_QueryInterface
,
2924 ShellLink_ContextMenu_AddRef
,
2925 ShellLink_ContextMenu_Release
,
2926 ShellLink_QueryContextMenu
,
2927 ShellLink_InvokeCommand
,
2928 ShellLink_GetCommandString
2931 static HRESULT WINAPI
2932 ShellLink_ObjectWithSite_QueryInterface( IObjectWithSite
* iface
, REFIID riid
, void** ppvObject
)
2934 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2935 return ShellLink_QueryInterface( This
, riid
, ppvObject
);
2939 ShellLink_ObjectWithSite_AddRef( IObjectWithSite
* iface
)
2941 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2942 return ShellLink_AddRef( This
);
2946 ShellLink_ObjectWithSite_Release( IObjectWithSite
* iface
)
2948 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2949 return ShellLink_Release( This
);
2952 static HRESULT WINAPI
2953 ShellLink_GetSite( IObjectWithSite
*iface
, REFIID iid
, void ** ppvSite
)
2955 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2957 TRACE("%p %s %p\n", This
, debugstr_guid( iid
), ppvSite
);
2961 return IUnknown_QueryInterface( This
->site
, iid
, ppvSite
);
2964 static HRESULT WINAPI
2965 ShellLink_SetSite( IObjectWithSite
*iface
, IUnknown
*punk
)
2967 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2969 TRACE("%p %p\n", iface
, punk
);
2972 IUnknown_AddRef( punk
);
2978 static const IObjectWithSiteVtbl owsvt
=
2980 ShellLink_ObjectWithSite_QueryInterface
,
2981 ShellLink_ObjectWithSite_AddRef
,
2982 ShellLink_ObjectWithSite_Release
,