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
)
195 len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
196 p
= HeapAlloc( heap
, flags
, len
*sizeof (WCHAR
) );
199 MultiByteToWideChar( CP_ACP
, 0, str
, -1, p
, len
);
203 static LPWSTR __inline
strdupW( LPCWSTR src
)
206 if (!src
) return NULL
;
207 dest
= HeapAlloc( GetProcessHeap(), 0, (wcslen(src
)+1)*sizeof(WCHAR
) );
213 /**************************************************************************
214 * ShellLink::QueryInterface implementation
216 static HRESULT
ShellLink_QueryInterface( IShellLinkImpl
*This
, REFIID riid
, LPVOID
*ppvObj
)
218 TRACE("(%p)->(\n\tIID:\t%s)\n",This
,debugstr_guid(riid
));
222 if(IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IShellLinkA
))
226 else if(IsEqualIID(riid
, &IID_IShellLinkW
))
228 *ppvObj
= &(This
->lpvtblw
);
230 else if(IsEqualIID(riid
, &IID_IPersistFile
))
232 *ppvObj
= &(This
->lpvtblPersistFile
);
234 else if(IsEqualIID(riid
, &IID_IPersistStream
))
236 *ppvObj
= &(This
->lpvtblPersistStream
);
238 else if(IsEqualIID(riid
, &IID_IShellLinkDataList
))
240 *ppvObj
= &(This
->lpvtblShellLinkDataList
);
242 else if(IsEqualIID(riid
, &IID_IShellExtInit
))
244 *ppvObj
= &(This
->lpvtblShellExtInit
);
246 else if(IsEqualIID(riid
, &IID_IContextMenu
))
248 *ppvObj
= &(This
->lpvtblContextMenu
);
250 else if(IsEqualIID(riid
, &IID_IObjectWithSite
))
252 *ppvObj
= &(This
->lpvtblObjectWithSite
);
254 else if(IsEqualIID(riid
, &IID_IShellPropSheetExt
))
256 *ppvObj
= &(This
->lpvtblPropSheetExt
);
261 IUnknown_AddRef((IUnknown
*)(*ppvObj
));
262 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
265 ERR("-- Interface: E_NOINTERFACE\n");
266 return E_NOINTERFACE
;
269 /**************************************************************************
270 * ShellLink::AddRef implementation
272 static ULONG
ShellLink_AddRef( IShellLinkImpl
*This
)
274 ULONG refCount
= InterlockedIncrement(&This
->ref
);
276 TRACE("(%p)->(count=%u)\n", This
, refCount
- 1);
281 /**************************************************************************
282 * ShellLink::Release implementation
284 static ULONG
ShellLink_Release( IShellLinkImpl
*This
)
286 ULONG refCount
= InterlockedDecrement(&This
->ref
);
288 TRACE("(%p)->(count=%u)\n", This
, refCount
+ 1);
293 TRACE("-- destroying IShellLink(%p)\n",This
);
295 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
296 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
297 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
298 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
299 HeapFree(GetProcessHeap(),0,This
->sPath
);
300 HeapFree(GetProcessHeap(),0,This
->sLinkPath
);
303 IUnknown_Release( This
->site
);
313 static HRESULT
ShellLink_GetClassID( IShellLinkImpl
*This
, CLSID
*pclsid
)
315 TRACE("%p %p\n", This
, pclsid
);
317 *pclsid
= CLSID_ShellLink
;
321 /**************************************************************************
322 * IPersistFile_QueryInterface
324 static HRESULT WINAPI
IPersistFile_fnQueryInterface(
329 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
330 return ShellLink_QueryInterface( This
, riid
, ppvObj
);
333 /******************************************************************************
334 * IPersistFile_AddRef
336 static ULONG WINAPI
IPersistFile_fnAddRef(IPersistFile
* iface
)
338 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
339 return ShellLink_AddRef( This
);
342 /******************************************************************************
343 * IPersistFile_Release
345 static ULONG WINAPI
IPersistFile_fnRelease(IPersistFile
* iface
)
347 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
348 return IShellLinkA_Release((IShellLinkA
*)This
);
351 static HRESULT WINAPI
IPersistFile_fnGetClassID(IPersistFile
* iface
, CLSID
*pClassID
)
353 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
354 return ShellLink_GetClassID( This
, pClassID
);
357 static HRESULT WINAPI
IPersistFile_fnIsDirty(IPersistFile
* iface
)
359 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
361 TRACE("(%p)\n",This
);
369 static HRESULT WINAPI
IPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
371 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
372 IPersistStream
*StreamThis
= (IPersistStream
*)&This
->lpvtblPersistStream
;
376 TRACE("(%p, %s, %x)\n",This
, debugstr_w(pszFileName
), dwMode
);
379 dwMode
= STGM_READ
| STGM_SHARE_DENY_WRITE
;
380 r
= SHCreateStreamOnFileW(pszFileName
, dwMode
, &stm
);
383 HeapFree(GetProcessHeap(), 0, This
->sLinkPath
);
384 This
->sLinkPath
= strdupW(pszFileName
);
385 r
= IPersistStream_Load(StreamThis
, stm
);
386 ShellLink_UpdatePath(This
->sPathRel
, pszFileName
, This
->sWorkDir
, &This
->sPath
);
387 IStream_Release( stm
);
388 This
->bDirty
= FALSE
;
390 TRACE("-- returning hr %08x\n", r
);
394 static BOOL
StartLinkProcessor( LPCOLESTR szLink
)
396 static const WCHAR szFormat
[] = {
397 'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',
398 ' ','-','w',' ','"','%','s','"',0 };
402 PROCESS_INFORMATION pi
;
405 len
= sizeof(szFormat
) + wcslen( szLink
) * sizeof(WCHAR
);
406 buffer
= HeapAlloc( GetProcessHeap(), 0, len
);
410 swprintf( buffer
, szFormat
, szLink
);
412 TRACE("starting %s\n",debugstr_w(buffer
));
414 memset(&si
, 0, sizeof(si
));
417 ret
= CreateProcessW( NULL
, buffer
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
419 HeapFree( GetProcessHeap(), 0, buffer
);
423 CloseHandle( pi
.hProcess
);
424 CloseHandle( pi
.hThread
);
430 static HRESULT WINAPI
IPersistFile_fnSave(IPersistFile
* iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
432 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
433 IPersistStream
*StreamThis
= (IPersistStream
*)&This
->lpvtblPersistStream
;
437 TRACE("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
442 r
= SHCreateStreamOnFileW( pszFileName
, STGM_READWRITE
| STGM_CREATE
| STGM_SHARE_EXCLUSIVE
, &stm
);
445 r
= IPersistStream_Save(StreamThis
, stm
, FALSE
);
446 IStream_Release( stm
);
450 if ( This
->sLinkPath
)
452 HeapFree(GetProcessHeap(), 0, This
->sLinkPath
);
454 This
->sLinkPath
= HeapAlloc(GetProcessHeap(), 0, (wcslen(pszFileName
)+1) * sizeof(WCHAR
));
455 if ( This
->sLinkPath
)
457 wcscpy(This
->sLinkPath
, pszFileName
);
460 StartLinkProcessor( pszFileName
);
462 This
->bDirty
= FALSE
;
466 DeleteFileW( pszFileName
);
467 WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName
) );
474 static HRESULT WINAPI
IPersistFile_fnSaveCompleted(IPersistFile
* iface
, LPCOLESTR pszFileName
)
476 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
477 FIXME("(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
481 static HRESULT WINAPI
IPersistFile_fnGetCurFile(IPersistFile
* iface
, LPOLESTR
*ppszFileName
)
483 IShellLinkImpl
*This
= impl_from_IPersistFile(iface
);
485 *ppszFileName
= NULL
;
487 if ( !This
->sLinkPath
)
489 /* IPersistFile::GetCurFile called before IPersistFile::Save */
493 *ppszFileName
= CoTaskMemAlloc((wcslen(This
->sLinkPath
)+1) * sizeof(WCHAR
));
497 return E_OUTOFMEMORY
;
500 /* copy last saved filename */
501 wcscpy(*ppszFileName
, This
->sLinkPath
);
506 static const IPersistFileVtbl pfvt
=
508 IPersistFile_fnQueryInterface
,
509 IPersistFile_fnAddRef
,
510 IPersistFile_fnRelease
,
511 IPersistFile_fnGetClassID
,
512 IPersistFile_fnIsDirty
,
515 IPersistFile_fnSaveCompleted
,
516 IPersistFile_fnGetCurFile
519 /************************************************************************
520 * IPersistStream_QueryInterface
522 static HRESULT WINAPI
IPersistStream_fnQueryInterface(
523 IPersistStream
* iface
,
527 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
528 return ShellLink_QueryInterface( This
, riid
, ppvObj
);
531 /************************************************************************
532 * IPersistStream_Release
534 static ULONG WINAPI
IPersistStream_fnRelease(
535 IPersistStream
* iface
)
537 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
538 return IShellLinkA_Release((IShellLinkA
*)This
);
541 /************************************************************************
542 * IPersistStream_AddRef
544 static ULONG WINAPI
IPersistStream_fnAddRef(
545 IPersistStream
* iface
)
547 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
548 return ShellLink_AddRef( This
);
551 /************************************************************************
552 * IPersistStream_GetClassID
555 static HRESULT WINAPI
IPersistStream_fnGetClassID(
556 IPersistStream
* iface
,
559 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
560 return ShellLink_GetClassID( This
, pClassID
);
563 /************************************************************************
564 * IPersistStream_IsDirty (IPersistStream)
566 static HRESULT WINAPI
IPersistStream_fnIsDirty(
567 IPersistStream
* iface
)
569 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
571 TRACE("(%p)\n", This
);
577 static HRESULT
Stream_LoadString( IStream
* stm
, BOOL unicode
, LPWSTR
*pstr
)
588 r
= IStream_Read(stm
, &len
, sizeof(len
), &count
);
589 if ( FAILED (r
) || ( count
!= sizeof(len
) ) )
593 len
*= sizeof (WCHAR
);
595 TRACE("reading %d\n", len
);
596 temp
= HeapAlloc(GetProcessHeap(), 0, len
+sizeof(WCHAR
));
598 return E_OUTOFMEMORY
;
600 r
= IStream_Read(stm
, temp
, len
, &count
);
601 if( FAILED (r
) || ( count
!= len
) )
603 HeapFree( GetProcessHeap(), 0, temp
);
607 TRACE("read %s\n", debugstr_an(temp
,len
));
609 /* convert to unicode if necessary */
612 count
= MultiByteToWideChar( CP_ACP
, 0, temp
, len
, NULL
, 0 );
613 str
= HeapAlloc( GetProcessHeap(), 0, (count
+1)*sizeof (WCHAR
) );
616 HeapFree( GetProcessHeap(), 0, temp
);
617 return E_OUTOFMEMORY
;
619 MultiByteToWideChar( CP_ACP
, 0, temp
, len
, str
, count
);
620 HeapFree( GetProcessHeap(), 0, temp
);
634 static HRESULT
Stream_ReadChunk( IStream
* stm
, LPVOID
*data
)
641 unsigned char data
[1];
646 r
= IStream_Read( stm
, &size
, sizeof(size
), &count
);
647 if( FAILED( r
) || count
!= sizeof(size
) )
650 chunk
= HeapAlloc( GetProcessHeap(), 0, size
);
652 return E_OUTOFMEMORY
;
655 r
= IStream_Read( stm
, chunk
->data
, size
- sizeof(size
), &count
);
656 if( FAILED( r
) || count
!= (size
- sizeof(size
)) )
658 HeapFree( GetProcessHeap(), 0, chunk
);
662 TRACE("Read %d bytes\n",chunk
->size
);
669 static BOOL
Stream_LoadVolume( LOCAL_VOLUME_INFO
*vol
, volume_info
*volume
)
671 const int label_sz
= sizeof volume
->label
/sizeof volume
->label
[0];
675 volume
->serial
= vol
->dwVolSerial
;
676 volume
->type
= vol
->dwType
;
678 if( !vol
->dwVolLabelOfs
)
680 if( vol
->dwSize
<= vol
->dwVolLabelOfs
)
682 len
= vol
->dwSize
- vol
->dwVolLabelOfs
;
685 label
+= vol
->dwVolLabelOfs
;
686 MultiByteToWideChar( CP_ACP
, 0, label
, len
, volume
->label
, label_sz
-1);
691 static LPWSTR
Stream_LoadPath( LPCSTR p
, DWORD maxlen
)
696 while( p
[len
] && (len
< maxlen
) )
699 wlen
= MultiByteToWideChar(CP_ACP
, 0, p
, len
, NULL
, 0);
700 path
= HeapAlloc(GetProcessHeap(), 0, (wlen
+1)*sizeof(WCHAR
));
701 MultiByteToWideChar(CP_ACP
, 0, p
, len
, path
, wlen
);
707 static HRESULT
Stream_LoadLocation( IStream
*stm
,
708 volume_info
*volume
, LPWSTR
*path
)
715 r
= Stream_ReadChunk( stm
, (LPVOID
*) &p
);
719 loc
= (LOCATION_INFO
*) p
;
720 if (loc
->dwTotalSize
< sizeof(LOCATION_INFO
))
722 HeapFree( GetProcessHeap(), 0, p
);
726 /* if there's valid local volume information, load it */
727 if( loc
->dwVolTableOfs
&&
728 ((loc
->dwVolTableOfs
+ sizeof(LOCAL_VOLUME_INFO
)) <= loc
->dwTotalSize
) )
730 LOCAL_VOLUME_INFO
*volume_info
;
732 volume_info
= (LOCAL_VOLUME_INFO
*) &p
[loc
->dwVolTableOfs
];
733 Stream_LoadVolume( volume_info
, volume
);
736 /* if there's a local path, load it */
737 n
= loc
->dwLocalPathOfs
;
738 if( n
&& (n
< loc
->dwTotalSize
) )
739 *path
= Stream_LoadPath( &p
[n
], loc
->dwTotalSize
- n
);
741 TRACE("type %d serial %08x name %s path %s\n", volume
->type
,
742 volume
->serial
, debugstr_w(volume
->label
), debugstr_w(*path
));
744 HeapFree( GetProcessHeap(), 0, p
);
749 * The format of the advertised shortcut info seems to be:
754 * 0 Length of the block (4 bytes, usually 0x314)
756 * 8 string data in ASCII
757 * 8+0x104 string data in UNICODE
759 * In the original Win32 implementation the buffers are not initialized
760 * to zero, so data trailing the string is random garbage.
762 static HRESULT
Stream_LoadAdvertiseInfo( IStream
* stm
, LPWSTR
*str
)
767 EXP_DARWIN_LINK buffer
;
771 r
= IStream_Read( stm
, &buffer
.dbh
.cbSize
, sizeof (DWORD
), &count
);
775 /* make sure that we read the size of the structure even on error */
776 size
= sizeof buffer
- sizeof (DWORD
);
777 if( buffer
.dbh
.cbSize
!= sizeof buffer
)
779 ERR("Ooops. This structure is not as expected...\n");
783 r
= IStream_Read( stm
, &buffer
.dbh
.dwSignature
, size
, &count
);
790 TRACE("magic %08x string = %s\n", buffer
.dbh
.dwSignature
, debugstr_w(buffer
.szwDarwinID
));
792 if( (buffer
.dbh
.dwSignature
&0xffff0000) != 0xa0000000 )
794 ERR("Unknown magic number %08x in advertised shortcut\n", buffer
.dbh
.dwSignature
);
798 *str
= HeapAlloc( GetProcessHeap(), 0,
799 (wcslen(buffer
.szwDarwinID
)+1) * sizeof(WCHAR
) );
800 wcscpy( *str
, buffer
.szwDarwinID
);
805 /************************************************************************
806 * IPersistStream_Load (IPersistStream)
808 static HRESULT WINAPI
IPersistStream_fnLoad(
809 IPersistStream
* iface
,
818 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
820 TRACE("%p %p\n", This
, stm
);
823 return STG_E_INVALIDPOINTER
;
826 r
= IStream_Read(stm
, &hdr
, sizeof(hdr
), &dwBytesRead
);
830 if( dwBytesRead
!= sizeof(hdr
))
832 if( hdr
.dwSize
!= sizeof(hdr
))
834 if( !IsEqualIID(&hdr
.MagicGuid
, &CLSID_ShellLink
) )
837 /* free all the old stuff */
840 memset( &This
->volume
, 0, sizeof This
->volume
);
841 HeapFree(GetProcessHeap(), 0, This
->sPath
);
843 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
844 This
->sDescription
= NULL
;
845 HeapFree(GetProcessHeap(), 0, This
->sPathRel
);
846 This
->sPathRel
= NULL
;
847 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
848 This
->sWorkDir
= NULL
;
849 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
851 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
852 This
->sIcoPath
= NULL
;
853 HeapFree(GetProcessHeap(), 0, This
->sProduct
);
854 This
->sProduct
= NULL
;
855 HeapFree(GetProcessHeap(), 0, This
->sComponent
);
856 This
->sComponent
= NULL
;
858 This
->wHotKey
= (WORD
)hdr
.wHotKey
;
859 This
->iIcoNdx
= hdr
.nIcon
;
860 FileTimeToSystemTime (&hdr
.Time1
, &This
->time1
);
861 FileTimeToSystemTime (&hdr
.Time2
, &This
->time2
);
862 FileTimeToSystemTime (&hdr
.Time3
, &This
->time3
);
865 WCHAR sTemp
[MAX_PATH
];
866 GetDateFormatW(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
, &This
->time1
,
867 NULL
, sTemp
, sizeof(sTemp
)/sizeof(*sTemp
));
868 TRACE("-- time1: %s\n", debugstr_w(sTemp
) );
869 GetDateFormatW(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
, &This
->time2
,
870 NULL
, sTemp
, sizeof(sTemp
)/sizeof(*sTemp
));
871 TRACE("-- time2: %s\n", debugstr_w(sTemp
) );
872 GetDateFormatW(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
, &This
->time3
,
873 NULL
, sTemp
, sizeof(sTemp
)/sizeof(*sTemp
));
874 TRACE("-- time3: %s\n", debugstr_w(sTemp
) );
877 /* load all the new stuff */
878 if( hdr
.dwFlags
& SLDF_HAS_ID_LIST
)
880 r
= ILLoadFromStream( stm
, &This
->pPidl
);
886 /* load the location information */
887 if( hdr
.dwFlags
& SLDF_HAS_LINK_INFO
)
888 r
= Stream_LoadLocation( stm
, &This
->volume
, &This
->sPath
);
892 unicode
= hdr
.dwFlags
& SLDF_UNICODE
;
893 if( hdr
.dwFlags
& SLDF_HAS_NAME
)
895 r
= Stream_LoadString( stm
, unicode
, &This
->sDescription
);
896 TRACE("Description -> %s\n",debugstr_w(This
->sDescription
));
901 if( hdr
.dwFlags
& SLDF_HAS_RELPATH
)
903 r
= Stream_LoadString( stm
, unicode
, &This
->sPathRel
);
904 TRACE("Relative Path-> %s\n",debugstr_w(This
->sPathRel
));
909 if( hdr
.dwFlags
& SLDF_HAS_WORKINGDIR
)
911 r
= Stream_LoadString( stm
, unicode
, &This
->sWorkDir
);
912 TRACE("Working Dir -> %s\n",debugstr_w(This
->sWorkDir
));
917 if( hdr
.dwFlags
& SLDF_HAS_ARGS
)
919 r
= Stream_LoadString( stm
, unicode
, &This
->sArgs
);
920 TRACE("Working Dir -> %s\n",debugstr_w(This
->sArgs
));
925 if( hdr
.dwFlags
& SLDF_HAS_ICONLOCATION
)
927 r
= Stream_LoadString( stm
, unicode
, &This
->sIcoPath
);
928 TRACE("Icon file -> %s\n",debugstr_w(This
->sIcoPath
));
933 #if (NTDDI_VERSION < NTDDI_LONGHORN)
934 if( hdr
.dwFlags
& SLDF_HAS_LOGO3ID
)
936 r
= Stream_LoadAdvertiseInfo( stm
, &This
->sProduct
);
937 TRACE("Product -> %s\n",debugstr_w(This
->sProduct
));
943 if( hdr
.dwFlags
& SLDF_HAS_DARWINID
)
945 r
= Stream_LoadAdvertiseInfo( stm
, &This
->sComponent
);
946 TRACE("Component -> %s\n",debugstr_w(This
->sComponent
));
948 if( hdr
.dwFlags
& SLDF_RUNAS_USER
)
954 This
->bRunAs
= FALSE
;
960 r
= IStream_Read(stm
, &zero
, sizeof zero
, &dwBytesRead
);
961 if( FAILED( r
) || zero
|| dwBytesRead
!= sizeof zero
)
962 ERR("Last word was not zero\n");
973 /************************************************************************
976 * Helper function for IPersistStream_Save. Writes a unicode string
977 * with terminating nul byte to a stream, preceded by the its length.
979 static HRESULT
Stream_WriteString( IStream
* stm
, LPCWSTR str
)
981 USHORT len
= wcslen( str
) + 1;
985 r
= IStream_Write( stm
, &len
, sizeof(len
), &count
);
989 len
*= sizeof(WCHAR
);
991 r
= IStream_Write( stm
, str
, len
, &count
);
998 /************************************************************************
999 * Stream_WriteLocationInfo
1001 * Writes the location info to a stream
1003 * FIXME: One day we might want to write the network volume information
1004 * and the final path.
1005 * Figure out how Windows deals with unicode paths here.
1007 static HRESULT
Stream_WriteLocationInfo( IStream
* stm
, LPCWSTR path
,
1008 volume_info
*volume
)
1010 DWORD total_size
, path_size
, volume_info_size
, label_size
, final_path_size
;
1011 LOCAL_VOLUME_INFO
*vol
;
1013 LPSTR szLabel
, szPath
, szFinalPath
;
1017 TRACE("%p %s %p\n", stm
, debugstr_w(path
), volume
);
1019 /* figure out the size of everything */
1020 label_size
= WideCharToMultiByte( CP_ACP
, 0, volume
->label
, -1,
1021 NULL
, 0, NULL
, NULL
);
1022 path_size
= WideCharToMultiByte( CP_ACP
, 0, path
, -1,
1023 NULL
, 0, NULL
, NULL
);
1024 volume_info_size
= sizeof *vol
+ label_size
;
1025 final_path_size
= 1;
1026 total_size
= sizeof *loc
+ volume_info_size
+ path_size
+ final_path_size
;
1028 /* create pointers to everything */
1029 loc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, total_size
);
1030 vol
= (LOCAL_VOLUME_INFO
*) &loc
[1];
1031 szLabel
= (LPSTR
) &vol
[1];
1032 szPath
= &szLabel
[label_size
];
1033 szFinalPath
= &szPath
[path_size
];
1035 /* fill in the location information header */
1036 loc
->dwTotalSize
= total_size
;
1037 loc
->dwHeaderSize
= sizeof (*loc
);
1039 loc
->dwVolTableOfs
= sizeof (*loc
);
1040 loc
->dwLocalPathOfs
= sizeof (*loc
) + volume_info_size
;
1041 loc
->dwNetworkVolTableOfs
= 0;
1042 loc
->dwFinalPathOfs
= sizeof (*loc
) + volume_info_size
+ path_size
;
1044 /* fill in the volume information */
1045 vol
->dwSize
= volume_info_size
;
1046 vol
->dwType
= volume
->type
;
1047 vol
->dwVolSerial
= volume
->serial
;
1048 vol
->dwVolLabelOfs
= sizeof (*vol
);
1050 /* copy in the strings */
1051 WideCharToMultiByte( CP_ACP
, 0, volume
->label
, -1,
1052 szLabel
, label_size
, NULL
, NULL
);
1053 WideCharToMultiByte( CP_ACP
, 0, path
, -1,
1054 szPath
, path_size
, NULL
, NULL
);
1057 hr
= IStream_Write( stm
, loc
, total_size
, &count
);
1058 HeapFree(GetProcessHeap(), 0, loc
);
1063 static EXP_DARWIN_LINK
* shelllink_build_darwinid( LPCWSTR string
, DWORD magic
)
1065 EXP_DARWIN_LINK
*buffer
;
1067 buffer
= LocalAlloc( LMEM_ZEROINIT
, sizeof *buffer
);
1068 buffer
->dbh
.cbSize
= sizeof *buffer
;
1069 buffer
->dbh
.dwSignature
= magic
;
1070 lstrcpynW( buffer
->szwDarwinID
, string
, MAX_PATH
);
1071 WideCharToMultiByte(CP_ACP
, 0, string
, -1, buffer
->szDarwinID
, MAX_PATH
, NULL
, NULL
);
1076 static HRESULT
Stream_WriteAdvertiseInfo( IStream
* stm
, LPCWSTR string
, DWORD magic
)
1078 EXP_DARWIN_LINK
*buffer
;
1083 buffer
= shelllink_build_darwinid( string
, magic
);
1085 return IStream_Write( stm
, buffer
, buffer
->dbh
.cbSize
, &count
);
1088 /************************************************************************
1089 * IPersistStream_Save (IPersistStream)
1091 * FIXME: makes assumptions about byte order
1093 static HRESULT WINAPI
IPersistStream_fnSave(
1094 IPersistStream
* iface
,
1103 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
1105 TRACE("%p %p %x\n", This
, stm
, fClearDirty
);
1107 memset(&header
, 0, sizeof(header
));
1108 header
.dwSize
= sizeof(header
);
1109 header
.fStartup
= This
->iShowCmd
;
1110 header
.MagicGuid
= CLSID_ShellLink
;
1112 header
.wHotKey
= This
->wHotKey
;
1113 header
.nIcon
= This
->iIcoNdx
;
1114 header
.dwFlags
= SLDF_UNICODE
; /* strings are in unicode */
1116 header
.dwFlags
|= SLDF_HAS_ID_LIST
;
1118 header
.dwFlags
|= SLDF_HAS_LINK_INFO
;
1119 if( This
->sDescription
)
1120 header
.dwFlags
|= SLDF_HAS_NAME
;
1121 if( This
->sWorkDir
)
1122 header
.dwFlags
|= SLDF_HAS_WORKINGDIR
;
1124 header
.dwFlags
|= SLDF_HAS_ARGS
;
1125 if( This
->sIcoPath
)
1126 header
.dwFlags
|= SLDF_HAS_ICONLOCATION
;
1127 #if (NTDDI_VERSION < NTDDI_LONGHORN)
1128 if( This
->sProduct
)
1129 header
.dwFlags
|= SLDF_HAS_LOGO3ID
;
1131 if( This
->sComponent
)
1132 header
.dwFlags
|= SLDF_HAS_DARWINID
;
1134 header
.dwFlags
|= SLDF_RUNAS_USER
;
1136 SystemTimeToFileTime ( &This
->time1
, &header
.Time1
);
1137 SystemTimeToFileTime ( &This
->time2
, &header
.Time2
);
1138 SystemTimeToFileTime ( &This
->time3
, &header
.Time3
);
1140 /* write the Shortcut header */
1141 r
= IStream_Write( stm
, &header
, sizeof(header
), &count
);
1144 ERR("Write failed at %d\n",__LINE__
);
1148 TRACE("Writing pidl\n");
1150 /* write the PIDL to the shortcut */
1153 r
= ILSaveToStream( stm
, This
->pPidl
);
1156 ERR("Failed to write PIDL at %d\n",__LINE__
);
1162 Stream_WriteLocationInfo( stm
, This
->sPath
, &This
->volume
);
1164 if( This
->sDescription
)
1165 r
= Stream_WriteString( stm
, This
->sDescription
);
1167 if( This
->sPathRel
)
1168 r
= Stream_WriteString( stm
, This
->sPathRel
);
1170 if( This
->sWorkDir
)
1171 r
= Stream_WriteString( stm
, This
->sWorkDir
);
1174 r
= Stream_WriteString( stm
, This
->sArgs
);
1176 if( This
->sIcoPath
)
1177 r
= Stream_WriteString( stm
, This
->sIcoPath
);
1179 if( This
->sProduct
)
1180 r
= Stream_WriteAdvertiseInfo( stm
, This
->sProduct
, EXP_SZ_ICON_SIG
);
1182 if( This
->sComponent
)
1183 r
= Stream_WriteAdvertiseInfo( stm
, This
->sComponent
, EXP_DARWIN_ID_SIG
);
1185 /* the last field is a single zero dword */
1187 r
= IStream_Write( stm
, &zero
, sizeof zero
, &count
);
1192 /************************************************************************
1193 * IPersistStream_GetSizeMax (IPersistStream)
1195 static HRESULT WINAPI
IPersistStream_fnGetSizeMax(
1196 IPersistStream
* iface
,
1197 ULARGE_INTEGER
* pcbSize
)
1199 IShellLinkImpl
*This
= impl_from_IPersistStream(iface
);
1201 TRACE("(%p)\n", This
);
1206 static const IPersistStreamVtbl psvt
=
1208 IPersistStream_fnQueryInterface
,
1209 IPersistStream_fnAddRef
,
1210 IPersistStream_fnRelease
,
1211 IPersistStream_fnGetClassID
,
1212 IPersistStream_fnIsDirty
,
1213 IPersistStream_fnLoad
,
1214 IPersistStream_fnSave
,
1215 IPersistStream_fnGetSizeMax
1218 /**************************************************************************
1219 * IShellLink_Constructor
1221 HRESULT WINAPI
IShellLink_Constructor( IUnknown
*pUnkOuter
,
1222 REFIID riid
, LPVOID
*ppv
)
1224 IShellLinkImpl
* sl
;
1227 TRACE("unkOut=%p riid=%s\n",pUnkOuter
, debugstr_guid(riid
));
1232 return CLASS_E_NOAGGREGATION
;
1233 sl
= LocalAlloc(LMEM_ZEROINIT
,sizeof(IShellLinkImpl
));
1235 return E_OUTOFMEMORY
;
1239 sl
->lpvtblw
= &slvtw
;
1240 sl
->lpvtblPersistFile
= &pfvt
;
1241 sl
->lpvtblPersistStream
= &psvt
;
1242 sl
->lpvtblShellLinkDataList
= &dlvt
;
1243 sl
->lpvtblShellExtInit
= &eivt
;
1244 sl
->lpvtblContextMenu
= &cmvt
;
1245 sl
->lpvtblObjectWithSite
= &owsvt
;
1246 sl
->lpvtblPropSheetExt
= &pse
;
1247 sl
->iShowCmd
= SW_SHOWNORMAL
;
1253 TRACE("(%p)->()\n",sl
);
1255 r
= ShellLink_QueryInterface( sl
, riid
, ppv
);
1256 ShellLink_Release( sl
);
1261 static BOOL
SHELL_ExistsFileW(LPCWSTR path
)
1263 if (INVALID_FILE_ATTRIBUTES
== GetFileAttributesW(path
))
1268 /**************************************************************************
1269 * ShellLink_UpdatePath
1270 * update absolute path in sPath using relative path in sPathRel
1272 static HRESULT
ShellLink_UpdatePath(LPCWSTR sPathRel
, LPCWSTR path
, LPCWSTR sWorkDir
, LPWSTR
* psPath
)
1274 if (!path
|| !psPath
)
1275 return E_INVALIDARG
;
1277 if (!*psPath
&& sPathRel
) {
1278 WCHAR buffer
[2*MAX_PATH
], abs_path
[2*MAX_PATH
];
1279 LPWSTR final
= NULL
;
1281 /* first try if [directory of link file] + [relative path] finds an existing file */
1283 GetFullPathNameW( path
, MAX_PATH
*2, buffer
, &final
);
1286 wcscpy(final
, sPathRel
);
1290 if (SHELL_ExistsFileW(buffer
)) {
1291 if (!GetFullPathNameW(buffer
, MAX_PATH
, abs_path
, &final
))
1292 wcscpy(abs_path
, buffer
);
1294 /* try if [working directory] + [relative path] finds an existing file */
1296 wcscpy(buffer
, sWorkDir
);
1297 wcscpy(PathAddBackslashW(buffer
), sPathRel
);
1299 if (SHELL_ExistsFileW(buffer
))
1300 if (!GetFullPathNameW(buffer
, MAX_PATH
, abs_path
, &final
))
1301 wcscpy(abs_path
, buffer
);
1305 /* FIXME: This is even not enough - not all shell links can be resolved using this algorithm. */
1307 wcscpy(abs_path
, sPathRel
);
1309 *psPath
= HeapAlloc(GetProcessHeap(), 0, (wcslen(abs_path
)+1)*sizeof(WCHAR
));
1311 return E_OUTOFMEMORY
;
1313 wcscpy(*psPath
, abs_path
);
1319 /**************************************************************************
1320 * IShellLink_ConstructFromFile
1322 HRESULT WINAPI
IShellLink_ConstructFromFile( IUnknown
* pUnkOuter
, REFIID riid
,
1323 LPCITEMIDLIST pidl
, LPVOID
* ppv
)
1327 HRESULT hr
= IShellLink_Constructor(NULL
, riid
, (LPVOID
*)&psl
);
1329 if (SUCCEEDED(hr
)) {
1334 hr
= IShellLinkW_QueryInterface(psl
, &IID_IPersistFile
, (LPVOID
*)&ppf
);
1336 if (SUCCEEDED(hr
)) {
1337 WCHAR path
[MAX_PATH
];
1339 if (SHGetPathFromIDListW(pidl
, path
))
1340 hr
= IPersistFile_Load(ppf
, path
, 0);
1347 IPersistFile_Release(ppf
);
1351 IShellLinkW_Release(psl
);
1357 /**************************************************************************
1358 * IShellLinkA_QueryInterface
1360 static HRESULT WINAPI
IShellLinkA_fnQueryInterface( IShellLinkA
* iface
, REFIID riid
, LPVOID
*ppvObj
)
1362 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1363 return ShellLink_QueryInterface( This
, riid
, ppvObj
);
1366 /******************************************************************************
1367 * IShellLinkA_AddRef
1369 static ULONG WINAPI
IShellLinkA_fnAddRef(IShellLinkA
* iface
)
1371 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1372 return ShellLink_AddRef( This
);
1375 /******************************************************************************
1376 * IShellLinkA_Release
1378 static ULONG WINAPI
IShellLinkA_fnRelease(IShellLinkA
* iface
)
1380 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1381 return ShellLink_Release( This
);
1384 static HRESULT WINAPI
IShellLinkA_fnGetPath(IShellLinkA
* iface
, LPSTR pszFile
,
1385 INT cchMaxPath
, WIN32_FIND_DATAA
*pfd
, DWORD fFlags
)
1387 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1389 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1390 This
, pszFile
, cchMaxPath
, pfd
, fFlags
, debugstr_w(This
->sPath
));
1395 WideCharToMultiByte( CP_ACP
, 0, This
->sPath
, -1,
1396 pszFile
, cchMaxPath
, NULL
, NULL
);
1398 if (pfd
) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This
);
1403 static HRESULT WINAPI
IShellLinkA_fnGetIDList(IShellLinkA
* iface
, LPITEMIDLIST
* ppidl
)
1405 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1407 TRACE("(%p)->(ppidl=%p)\n",This
, ppidl
);
1409 return IShellLinkW_GetIDList((IShellLinkW
*)&(This
->lpvtblw
), ppidl
);
1412 static HRESULT WINAPI
IShellLinkA_fnSetIDList(IShellLinkA
* iface
, LPCITEMIDLIST pidl
)
1414 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1416 TRACE("(%p)->(pidl=%p)\n",This
, pidl
);
1419 ILFree(This
->pPidl
);
1420 This
->pPidl
= ILClone (pidl
);
1421 This
->bDirty
= TRUE
;
1426 static HRESULT WINAPI
IShellLinkA_fnGetDescription(IShellLinkA
* iface
, LPSTR pszName
,INT cchMaxName
)
1428 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1430 TRACE("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1434 if( This
->sDescription
)
1435 WideCharToMultiByte( CP_ACP
, 0, This
->sDescription
, -1,
1436 pszName
, cchMaxName
, NULL
, NULL
);
1441 static HRESULT WINAPI
IShellLinkA_fnSetDescription(IShellLinkA
* iface
, LPCSTR pszName
)
1443 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1445 TRACE("(%p)->(pName=%s)\n", This
, pszName
);
1447 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1448 This
->sDescription
= NULL
;
1451 This
->sDescription
= HEAP_strdupAtoW( GetProcessHeap(), 0, pszName
);
1452 if ( !This
->sDescription
)
1453 return E_OUTOFMEMORY
;
1455 This
->bDirty
= TRUE
;
1460 static HRESULT WINAPI
IShellLinkA_fnGetWorkingDirectory(IShellLinkA
* iface
, LPSTR pszDir
,INT cchMaxPath
)
1462 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1464 TRACE("(%p)->(%p len=%u)\n", This
, pszDir
, cchMaxPath
);
1468 if( This
->sWorkDir
)
1469 WideCharToMultiByte( CP_ACP
, 0, This
->sWorkDir
, -1,
1470 pszDir
, cchMaxPath
, NULL
, NULL
);
1475 static HRESULT WINAPI
IShellLinkA_fnSetWorkingDirectory(IShellLinkA
* iface
, LPCSTR pszDir
)
1477 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1479 TRACE("(%p)->(dir=%s)\n",This
, pszDir
);
1481 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1482 This
->sWorkDir
= NULL
;
1485 This
->sWorkDir
= HEAP_strdupAtoW( GetProcessHeap(), 0, pszDir
);
1486 if ( !This
->sWorkDir
)
1487 return E_OUTOFMEMORY
;
1489 This
->bDirty
= TRUE
;
1494 static HRESULT WINAPI
IShellLinkA_fnGetArguments(IShellLinkA
* iface
, LPSTR pszArgs
,INT cchMaxPath
)
1496 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1498 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1503 WideCharToMultiByte( CP_ACP
, 0, This
->sArgs
, -1,
1504 pszArgs
, cchMaxPath
, NULL
, NULL
);
1509 static HRESULT WINAPI
IShellLinkA_fnSetArguments(IShellLinkA
* iface
, LPCSTR pszArgs
)
1511 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1513 TRACE("(%p)->(args=%s)\n",This
, pszArgs
);
1515 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1519 This
->sArgs
= HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs
);
1521 return E_OUTOFMEMORY
;
1524 This
->bDirty
= TRUE
;
1529 static HRESULT WINAPI
IShellLinkA_fnGetHotkey(IShellLinkA
* iface
, WORD
*pwHotkey
)
1531 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1533 TRACE("(%p)->(%p)(0x%08x)\n",This
, pwHotkey
, This
->wHotKey
);
1535 *pwHotkey
= This
->wHotKey
;
1540 static HRESULT WINAPI
IShellLinkA_fnSetHotkey(IShellLinkA
* iface
, WORD wHotkey
)
1542 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1544 TRACE("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1546 This
->wHotKey
= wHotkey
;
1547 This
->bDirty
= TRUE
;
1552 static HRESULT WINAPI
IShellLinkA_fnGetShowCmd(IShellLinkA
* iface
, INT
*piShowCmd
)
1554 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1556 TRACE("(%p)->(%p)\n",This
, piShowCmd
);
1557 *piShowCmd
= This
->iShowCmd
;
1561 static HRESULT WINAPI
IShellLinkA_fnSetShowCmd(IShellLinkA
* iface
, INT iShowCmd
)
1563 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1565 TRACE("(%p) %d\n",This
, iShowCmd
);
1567 This
->iShowCmd
= iShowCmd
;
1568 This
->bDirty
= TRUE
;
1573 static HRESULT
SHELL_PidlGeticonLocationA(IShellFolder
* psf
, LPCITEMIDLIST pidl
,
1574 LPSTR pszIconPath
, int cchIconPath
, int* piIcon
)
1576 LPCITEMIDLIST pidlLast
;
1578 HRESULT hr
= SHBindToParent(pidl
, &IID_IShellFolder
, (LPVOID
*)&psf
, &pidlLast
);
1580 if (SUCCEEDED(hr
)) {
1583 hr
= IShellFolder_GetUIObjectOf(psf
, 0, 1, &pidlLast
, &IID_IExtractIconA
, NULL
, (LPVOID
*)&pei
);
1585 if (SUCCEEDED(hr
)) {
1586 hr
= IExtractIconA_GetIconLocation(pei
, 0, pszIconPath
, MAX_PATH
, piIcon
, NULL
);
1588 IExtractIconA_Release(pei
);
1591 IShellFolder_Release(psf
);
1597 static HRESULT WINAPI
IShellLinkA_fnGetIconLocation(IShellLinkA
* iface
, LPSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1599 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1601 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1604 *piIcon
= This
->iIcoNdx
;
1608 WideCharToMultiByte(CP_ACP
, 0, This
->sIcoPath
, -1, pszIconPath
, cchIconPath
, NULL
, NULL
);
1612 if (This
->pPidl
|| This
->sPath
)
1616 HRESULT hr
= SHGetDesktopFolder(&pdsk
);
1620 /* first look for an icon using the PIDL (if present) */
1622 hr
= SHELL_PidlGeticonLocationA(pdsk
, This
->pPidl
, pszIconPath
, cchIconPath
, piIcon
);
1626 /* if we couldn't find an icon yet, look for it using the file system path */
1627 if (FAILED(hr
) && This
->sPath
)
1631 hr
= IShellFolder_ParseDisplayName(pdsk
, 0, NULL
, This
->sPath
, NULL
, &pidl
, NULL
);
1633 if (SUCCEEDED(hr
)) {
1634 hr
= SHELL_PidlGeticonLocationA(pdsk
, pidl
, pszIconPath
, cchIconPath
, piIcon
);
1640 IShellFolder_Release(pdsk
);
1648 static HRESULT WINAPI
IShellLinkA_fnSetIconLocation(IShellLinkA
* iface
, LPCSTR pszIconPath
,INT iIcon
)
1650 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1652 TRACE("(%p)->(path=%s iicon=%u)\n",This
, pszIconPath
, iIcon
);
1654 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
1655 This
->sIcoPath
= NULL
;
1657 if ( pszIconPath
) {
1658 This
->sIcoPath
= HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath
);
1659 if ( !This
->sIcoPath
)
1660 return E_OUTOFMEMORY
;
1663 This
->iIcoNdx
= iIcon
;
1664 This
->bDirty
= TRUE
;
1669 static HRESULT WINAPI
IShellLinkA_fnSetRelativePath(IShellLinkA
* iface
, LPCSTR pszPathRel
, DWORD dwReserved
)
1671 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1673 TRACE("(%p)->(path=%s %x)\n",This
, pszPathRel
, dwReserved
);
1675 HeapFree(GetProcessHeap(), 0, This
->sPathRel
);
1676 This
->sPathRel
= NULL
;
1679 This
->sPathRel
= HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel
);
1681 if ( !This
->sPathRel
)
1682 return E_OUTOFMEMORY
;
1685 This
->bDirty
= TRUE
;
1687 return ShellLink_UpdatePath(This
->sPathRel
, This
->sPath
, This
->sWorkDir
, &This
->sPath
);
1690 static HRESULT WINAPI
IShellLinkA_fnResolve(IShellLinkA
* iface
, HWND hwnd
, DWORD fFlags
)
1692 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1694 TRACE("(%p)->(hwnd=%p flags=%x)\n",This
, hwnd
, fFlags
);
1696 return IShellLinkW_Resolve( (IShellLinkW
*)&(This
->lpvtblw
), hwnd
, fFlags
);
1699 static HRESULT WINAPI
IShellLinkA_fnSetPath(IShellLinkA
* iface
, LPCSTR pszFile
)
1703 IShellLinkImpl
*This
= (IShellLinkImpl
*)iface
;
1705 TRACE("(%p)->(path=%s)\n",This
, pszFile
);
1707 if (!pszFile
) return E_INVALIDARG
;
1709 str
= HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile
);
1711 return E_OUTOFMEMORY
;
1713 r
= IShellLinkW_SetPath((IShellLinkW
*)&(This
->lpvtblw
), str
);
1714 HeapFree( GetProcessHeap(), 0, str
);
1719 /**************************************************************************
1720 * IShellLink Implementation
1723 static const IShellLinkAVtbl slvt
=
1725 IShellLinkA_fnQueryInterface
,
1726 IShellLinkA_fnAddRef
,
1727 IShellLinkA_fnRelease
,
1728 IShellLinkA_fnGetPath
,
1729 IShellLinkA_fnGetIDList
,
1730 IShellLinkA_fnSetIDList
,
1731 IShellLinkA_fnGetDescription
,
1732 IShellLinkA_fnSetDescription
,
1733 IShellLinkA_fnGetWorkingDirectory
,
1734 IShellLinkA_fnSetWorkingDirectory
,
1735 IShellLinkA_fnGetArguments
,
1736 IShellLinkA_fnSetArguments
,
1737 IShellLinkA_fnGetHotkey
,
1738 IShellLinkA_fnSetHotkey
,
1739 IShellLinkA_fnGetShowCmd
,
1740 IShellLinkA_fnSetShowCmd
,
1741 IShellLinkA_fnGetIconLocation
,
1742 IShellLinkA_fnSetIconLocation
,
1743 IShellLinkA_fnSetRelativePath
,
1744 IShellLinkA_fnResolve
,
1745 IShellLinkA_fnSetPath
1749 /**************************************************************************
1750 * IShellLinkW_fnQueryInterface
1752 static HRESULT WINAPI
IShellLinkW_fnQueryInterface(
1753 IShellLinkW
* iface
, REFIID riid
, LPVOID
*ppvObj
)
1755 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1756 return ShellLink_QueryInterface( This
, riid
, ppvObj
);
1759 /******************************************************************************
1760 * IShellLinkW_fnAddRef
1762 static ULONG WINAPI
IShellLinkW_fnAddRef(IShellLinkW
* iface
)
1764 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1765 return ShellLink_AddRef( This
);
1768 /******************************************************************************
1769 * IShellLinkW_fnRelease
1771 static ULONG WINAPI
IShellLinkW_fnRelease(IShellLinkW
* iface
)
1773 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1774 return ShellLink_Release( This
);
1777 static HRESULT WINAPI
IShellLinkW_fnGetPath(IShellLinkW
* iface
, LPWSTR pszFile
,INT cchMaxPath
, WIN32_FIND_DATAW
*pfd
, DWORD fFlags
)
1779 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1781 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1782 This
, pszFile
, cchMaxPath
, pfd
, fFlags
, debugstr_w(This
->sPath
));
1784 if (This
->sComponent
|| This
->sProduct
)
1790 lstrcpynW( pszFile
, This
->sPath
, cchMaxPath
);
1792 if (pfd
) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This
);
1797 static HRESULT WINAPI
IShellLinkW_fnGetIDList(IShellLinkW
* iface
, LPITEMIDLIST
* ppidl
)
1799 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1801 TRACE("(%p)->(ppidl=%p)\n",This
, ppidl
);
1808 *ppidl
= ILClone(This
->pPidl
);
1812 static HRESULT WINAPI
IShellLinkW_fnSetIDList(IShellLinkW
* iface
, LPCITEMIDLIST pidl
)
1814 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1816 TRACE("(%p)->(pidl=%p)\n",This
, pidl
);
1819 ILFree( This
->pPidl
);
1820 This
->pPidl
= ILClone( pidl
);
1824 This
->bDirty
= TRUE
;
1829 static HRESULT WINAPI
IShellLinkW_fnGetDescription(IShellLinkW
* iface
, LPWSTR pszName
,INT cchMaxName
)
1831 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1833 TRACE("(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
1836 if( This
->sDescription
)
1837 lstrcpynW( pszName
, This
->sDescription
, cchMaxName
);
1842 static HRESULT WINAPI
IShellLinkW_fnSetDescription(IShellLinkW
* iface
, LPCWSTR pszName
)
1844 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1846 TRACE("(%p)->(desc=%s)\n",This
, debugstr_w(pszName
));
1848 HeapFree(GetProcessHeap(), 0, This
->sDescription
);
1849 This
->sDescription
= HeapAlloc( GetProcessHeap(), 0,
1850 (wcslen( pszName
)+1)*sizeof(WCHAR
) );
1851 if ( !This
->sDescription
)
1852 return E_OUTOFMEMORY
;
1854 wcscpy( This
->sDescription
, pszName
);
1855 This
->bDirty
= TRUE
;
1860 static HRESULT WINAPI
IShellLinkW_fnGetWorkingDirectory(IShellLinkW
* iface
, LPWSTR pszDir
,INT cchMaxPath
)
1862 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1864 TRACE("(%p)->(%p len %u)\n", This
, pszDir
, cchMaxPath
);
1868 if( This
->sWorkDir
)
1869 lstrcpynW( pszDir
, This
->sWorkDir
, cchMaxPath
);
1874 static HRESULT WINAPI
IShellLinkW_fnSetWorkingDirectory(IShellLinkW
* iface
, LPCWSTR pszDir
)
1876 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1878 TRACE("(%p)->(dir=%s)\n",This
, debugstr_w(pszDir
));
1880 HeapFree(GetProcessHeap(), 0, This
->sWorkDir
);
1881 This
->sWorkDir
= HeapAlloc( GetProcessHeap(), 0,
1882 (wcslen( pszDir
)+1)*sizeof (WCHAR
) );
1883 if ( !This
->sWorkDir
)
1884 return E_OUTOFMEMORY
;
1885 wcscpy( This
->sWorkDir
, pszDir
);
1886 This
->bDirty
= TRUE
;
1891 static HRESULT WINAPI
IShellLinkW_fnGetArguments(IShellLinkW
* iface
, LPWSTR pszArgs
,INT cchMaxPath
)
1893 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1895 TRACE("(%p)->(%p len=%u)\n", This
, pszArgs
, cchMaxPath
);
1900 lstrcpynW( pszArgs
, This
->sArgs
, cchMaxPath
);
1905 static HRESULT WINAPI
IShellLinkW_fnSetArguments(IShellLinkW
* iface
, LPCWSTR pszArgs
)
1907 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1909 TRACE("(%p)->(args=%s)\n",This
, debugstr_w(pszArgs
));
1911 HeapFree(GetProcessHeap(), 0, This
->sArgs
);
1912 This
->sArgs
= HeapAlloc( GetProcessHeap(), 0,
1913 (wcslen( pszArgs
)+1)*sizeof (WCHAR
) );
1915 return E_OUTOFMEMORY
;
1916 wcscpy( This
->sArgs
, pszArgs
);
1917 This
->bDirty
= TRUE
;
1922 static HRESULT WINAPI
IShellLinkW_fnGetHotkey(IShellLinkW
* iface
, WORD
*pwHotkey
)
1924 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1926 TRACE("(%p)->(%p)\n",This
, pwHotkey
);
1928 *pwHotkey
=This
->wHotKey
;
1933 static HRESULT WINAPI
IShellLinkW_fnSetHotkey(IShellLinkW
* iface
, WORD wHotkey
)
1935 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1937 TRACE("(%p)->(hotkey=%x)\n",This
, wHotkey
);
1939 This
->wHotKey
= wHotkey
;
1940 This
->bDirty
= TRUE
;
1945 static HRESULT WINAPI
IShellLinkW_fnGetShowCmd(IShellLinkW
* iface
, INT
*piShowCmd
)
1947 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1949 TRACE("(%p)->(%p)\n",This
, piShowCmd
);
1951 *piShowCmd
= This
->iShowCmd
;
1956 static HRESULT WINAPI
IShellLinkW_fnSetShowCmd(IShellLinkW
* iface
, INT iShowCmd
)
1958 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1960 This
->iShowCmd
= iShowCmd
;
1961 This
->bDirty
= TRUE
;
1966 static HRESULT
SHELL_PidlGeticonLocationW(IShellFolder
* psf
, LPCITEMIDLIST pidl
,
1967 LPWSTR pszIconPath
, int cchIconPath
, int* piIcon
)
1969 LPCITEMIDLIST pidlLast
;
1972 HRESULT hr
= SHBindToParent(pidl
, &IID_IShellFolder
, (LPVOID
*)&psf
, &pidlLast
);
1974 if (SUCCEEDED(hr
)) {
1977 hr
= IShellFolder_GetUIObjectOf(psf
, 0, 1, &pidlLast
, &IID_IExtractIconW
, NULL
, (LPVOID
*)&pei
);
1979 if (SUCCEEDED(hr
)) {
1980 hr
= IExtractIconW_GetIconLocation(pei
, 0, pszIconPath
, MAX_PATH
, piIcon
, &wFlags
);
1982 IExtractIconW_Release(pei
);
1985 IShellFolder_Release(psf
);
1991 static HRESULT WINAPI
IShellLinkW_fnGetIconLocation(IShellLinkW
* iface
, LPWSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1993 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
1995 TRACE("(%p)->(%p len=%u iicon=%p)\n", This
, pszIconPath
, cchIconPath
, piIcon
);
1998 *piIcon
= This
->iIcoNdx
;
2002 lstrcpynW(pszIconPath
, This
->sIcoPath
, cchIconPath
);
2006 if (This
->pPidl
|| This
->sPath
)
2010 HRESULT hr
= SHGetDesktopFolder(&pdsk
);
2014 /* first look for an icon using the PIDL (if present) */
2016 hr
= SHELL_PidlGeticonLocationW(pdsk
, This
->pPidl
, pszIconPath
, cchIconPath
, piIcon
);
2020 /* if we couldn't find an icon yet, look for it using the file system path */
2021 if (FAILED(hr
) && This
->sPath
)
2025 hr
= IShellFolder_ParseDisplayName(pdsk
, 0, NULL
, This
->sPath
, NULL
, &pidl
, NULL
);
2029 hr
= SHELL_PidlGeticonLocationW(pdsk
, pidl
, pszIconPath
, cchIconPath
, piIcon
);
2035 IShellFolder_Release(pdsk
);
2042 static HRESULT WINAPI
IShellLinkW_fnSetIconLocation(IShellLinkW
* iface
, LPCWSTR pszIconPath
,INT iIcon
)
2044 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
2046 TRACE("(%p)->(path=%s iicon=%u)\n",This
, debugstr_w(pszIconPath
), iIcon
);
2048 HeapFree(GetProcessHeap(), 0, This
->sIcoPath
);
2049 This
->sIcoPath
= HeapAlloc( GetProcessHeap(), 0,
2050 (wcslen( pszIconPath
)+1)*sizeof (WCHAR
) );
2051 if ( !This
->sIcoPath
)
2052 return E_OUTOFMEMORY
;
2053 wcscpy( This
->sIcoPath
, pszIconPath
);
2055 This
->iIcoNdx
= iIcon
;
2056 This
->bDirty
= TRUE
;
2061 static HRESULT WINAPI
IShellLinkW_fnSetRelativePath(IShellLinkW
* iface
, LPCWSTR pszPathRel
, DWORD dwReserved
)
2063 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
2065 TRACE("(%p)->(path=%s %x)\n",This
, debugstr_w(pszPathRel
), dwReserved
);
2067 HeapFree(GetProcessHeap(), 0, This
->sPathRel
);
2068 This
->sPathRel
= HeapAlloc( GetProcessHeap(), 0,
2069 (wcslen( pszPathRel
)+1) * sizeof (WCHAR
) );
2070 if ( !This
->sPathRel
)
2071 return E_OUTOFMEMORY
;
2072 wcscpy( This
->sPathRel
, pszPathRel
);
2073 This
->bDirty
= TRUE
;
2075 return ShellLink_UpdatePath(This
->sPathRel
, This
->sPath
, This
->sWorkDir
, &This
->sPath
);
2078 static HRESULT WINAPI
IShellLinkW_fnResolve(IShellLinkW
* iface
, HWND hwnd
, DWORD fFlags
)
2083 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
2085 TRACE("(%p)->(hwnd=%p flags=%x)\n",This
, hwnd
, fFlags
);
2087 /*FIXME: use IResolveShellLink interface */
2089 if (!This
->sPath
&& This
->pPidl
) {
2090 WCHAR buffer
[MAX_PATH
];
2092 bSuccess
= SHGetPathFromIDListW(This
->pPidl
, buffer
);
2094 if (bSuccess
&& *buffer
) {
2095 This
->sPath
= HeapAlloc(GetProcessHeap(), 0, (wcslen(buffer
)+1)*sizeof(WCHAR
));
2097 return E_OUTOFMEMORY
;
2099 wcscpy(This
->sPath
, buffer
);
2101 This
->bDirty
= TRUE
;
2103 hr
= S_OK
; /* don't report an error occurred while just caching information */
2106 if (!This
->sIcoPath
&& This
->sPath
) {
2107 This
->sIcoPath
= HeapAlloc(GetProcessHeap(), 0, (wcslen(This
->sPath
)+1)*sizeof(WCHAR
));
2108 if (!This
->sIcoPath
)
2109 return E_OUTOFMEMORY
;
2111 wcscpy(This
->sIcoPath
, This
->sPath
);
2114 This
->bDirty
= TRUE
;
2120 static LPWSTR
ShellLink_GetAdvertisedArg(LPCWSTR str
)
2129 p
= wcschr( str
, ':' );
2133 ret
= HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR
)*(len
+1));
2136 memcpy( ret
, str
, sizeof(WCHAR
)*len
);
2141 static HRESULT
ShellLink_SetAdvertiseInfo(IShellLinkImpl
*This
, LPCWSTR str
)
2143 LPCWSTR szComponent
= NULL
, szProduct
= NULL
, p
;
2151 /* each segment must start with two colons */
2152 if( str
[0] != ':' || str
[1] != ':' )
2155 /* the last segment is just two colons */
2160 /* there must be a colon straight after a guid */
2161 p
= wcschr( str
, ':' );
2168 /* get the guid, and check it's validly formatted */
2169 memcpy( szGuid
, str
, sizeof(WCHAR
)*len
);
2171 r
= CLSIDFromString( szGuid
, &guid
);
2176 /* match it up to a guid that we care about */
2177 if( IsEqualGUID( &guid
, &SHELL32_AdvtShortcutComponent
) && !szComponent
)
2179 else if( IsEqualGUID( &guid
, &SHELL32_AdvtShortcutProduct
) && !szProduct
)
2184 /* skip to the next field */
2185 str
= wcschr( str
, ':' );
2190 /* we have to have a component for an advertised shortcut */
2194 This
->sComponent
= ShellLink_GetAdvertisedArg( szComponent
);
2195 This
->sProduct
= ShellLink_GetAdvertisedArg( szProduct
);
2197 TRACE("Component = %s\n", debugstr_w(This
->sComponent
));
2198 TRACE("Product = %s\n", debugstr_w(This
->sProduct
));
2203 static BOOL
ShellLink_GetVolumeInfo(LPCWSTR path
, volume_info
*volume
)
2205 const int label_sz
= sizeof volume
->label
/sizeof volume
->label
[0];
2206 WCHAR drive
[4] = { path
[0], ':', '\\', 0 };
2209 volume
->type
= GetDriveTypeW(drive
);
2210 r
= GetVolumeInformationW(drive
, volume
->label
, label_sz
,
2211 &volume
->serial
, NULL
, NULL
, NULL
, 0);
2212 TRACE("r = %d type %d serial %08x name %s\n", r
,
2213 volume
->type
, volume
->serial
, debugstr_w(volume
->label
));
2217 static HRESULT WINAPI
IShellLinkW_fnSetPath(IShellLinkW
* iface
, LPCWSTR pszFile
)
2219 IShellLinkImpl
*This
= impl_from_IShellLinkW(iface
);
2220 WCHAR buffer
[MAX_PATH
];
2221 LPWSTR fname
, unquoted
= NULL
;
2225 TRACE("(%p)->(path=%s)\n",This
, debugstr_w(pszFile
));
2227 if (!pszFile
) return E_INVALIDARG
;
2229 /* quotes at the ends of the string are stripped */
2230 len
= wcslen(pszFile
);
2231 if (pszFile
[0] == '"' && pszFile
[len
-1] == '"')
2233 unquoted
= strdupW(pszFile
);
2234 PathUnquoteSpacesW(unquoted
);
2238 /* any other quote marks are invalid */
2239 if (wcschr(pszFile
, '"'))
2241 HeapFree(GetProcessHeap(), 0, unquoted
);
2245 HeapFree(GetProcessHeap(), 0, This
->sPath
);
2248 HeapFree(GetProcessHeap(), 0, This
->sComponent
);
2249 This
->sComponent
= NULL
;
2252 ILFree(This
->pPidl
);
2255 if (S_OK
!= ShellLink_SetAdvertiseInfo( This
, pszFile
))
2257 if (*pszFile
== '\0')
2259 else if (!GetFullPathNameW(pszFile
, MAX_PATH
, buffer
, &fname
))
2261 else if(!PathFileExistsW(buffer
) &&
2262 !SearchPathW(NULL
, pszFile
, NULL
, MAX_PATH
, buffer
, NULL
))
2265 This
->pPidl
= SHSimpleIDListFromPathW(pszFile
);
2266 ShellLink_GetVolumeInfo(buffer
, &This
->volume
);
2268 This
->sPath
= HeapAlloc( GetProcessHeap(), 0,
2269 (wcslen( buffer
)+1) * sizeof (WCHAR
) );
2271 return E_OUTOFMEMORY
;
2273 wcscpy(This
->sPath
, buffer
);
2275 This
->bDirty
= TRUE
;
2276 HeapFree(GetProcessHeap(), 0, unquoted
);
2281 /**************************************************************************
2282 * IShellLinkW Implementation
2285 static const IShellLinkWVtbl slvtw
=
2287 IShellLinkW_fnQueryInterface
,
2288 IShellLinkW_fnAddRef
,
2289 IShellLinkW_fnRelease
,
2290 IShellLinkW_fnGetPath
,
2291 IShellLinkW_fnGetIDList
,
2292 IShellLinkW_fnSetIDList
,
2293 IShellLinkW_fnGetDescription
,
2294 IShellLinkW_fnSetDescription
,
2295 IShellLinkW_fnGetWorkingDirectory
,
2296 IShellLinkW_fnSetWorkingDirectory
,
2297 IShellLinkW_fnGetArguments
,
2298 IShellLinkW_fnSetArguments
,
2299 IShellLinkW_fnGetHotkey
,
2300 IShellLinkW_fnSetHotkey
,
2301 IShellLinkW_fnGetShowCmd
,
2302 IShellLinkW_fnSetShowCmd
,
2303 IShellLinkW_fnGetIconLocation
,
2304 IShellLinkW_fnSetIconLocation
,
2305 IShellLinkW_fnSetRelativePath
,
2306 IShellLinkW_fnResolve
,
2307 IShellLinkW_fnSetPath
2310 static HRESULT WINAPI
2311 ShellLink_DataList_QueryInterface( IShellLinkDataList
* iface
, REFIID riid
, void** ppvObject
)
2313 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2314 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObject
);
2318 ShellLink_DataList_AddRef( IShellLinkDataList
* iface
)
2320 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2321 return IShellLinkA_AddRef((IShellLinkA
*)This
);
2325 ShellLink_DataList_Release( IShellLinkDataList
* iface
)
2327 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2328 return ShellLink_Release( This
);
2331 static HRESULT WINAPI
2332 ShellLink_AddDataBlock( IShellLinkDataList
* iface
, void* pDataBlock
)
2338 static HRESULT WINAPI
2339 ShellLink_CopyDataBlock( IShellLinkDataList
* iface
, DWORD dwSig
, void** ppDataBlock
)
2341 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2342 LPVOID block
= NULL
;
2345 TRACE("%p %08x %p\n", iface
, dwSig
, ppDataBlock
);
2349 case EXP_DARWIN_ID_SIG
:
2350 if (!This
->sComponent
)
2352 block
= shelllink_build_darwinid( This
->sComponent
, dwSig
);
2355 case EXP_SZ_LINK_SIG
:
2356 case NT_CONSOLE_PROPS_SIG
:
2357 case NT_FE_CONSOLE_PROPS_SIG
:
2358 case EXP_SPECIAL_FOLDER_SIG
:
2359 case EXP_SZ_ICON_SIG
:
2360 FIXME("valid but unhandled datablock %08x\n", dwSig
);
2363 ERR("unknown datablock %08x\n", dwSig
);
2365 *ppDataBlock
= block
;
2369 static HRESULT WINAPI
2370 ShellLink_RemoveDataBlock( IShellLinkDataList
* iface
, DWORD dwSig
)
2376 static HRESULT WINAPI
2377 ShellLink_GetFlags( IShellLinkDataList
* iface
, DWORD
* pdwFlags
)
2379 IShellLinkImpl
*This
= impl_from_IShellLinkDataList(iface
);
2382 FIXME("%p %p\n", This
, pdwFlags
);
2384 /* FIXME: add more */
2386 flags
|= SLDF_HAS_ARGS
;
2387 if (This
->sComponent
)
2388 flags
|= SLDF_HAS_DARWINID
;
2390 flags
|= SLDF_HAS_ICONLOCATION
;
2391 #if (NTDDI_VERSION < NTDDI_LONGHORN)
2393 flags
|= SLDF_HAS_LOGO3ID
;
2396 flags
|= SLDF_HAS_ID_LIST
;
2403 static HRESULT WINAPI
2404 ShellLink_SetFlags( IShellLinkDataList
* iface
, DWORD dwFlags
)
2410 static const IShellLinkDataListVtbl dlvt
=
2412 ShellLink_DataList_QueryInterface
,
2413 ShellLink_DataList_AddRef
,
2414 ShellLink_DataList_Release
,
2415 ShellLink_AddDataBlock
,
2416 ShellLink_CopyDataBlock
,
2417 ShellLink_RemoveDataBlock
,
2422 static HRESULT WINAPI
2423 ShellLink_ExtInit_QueryInterface( IShellExtInit
* iface
, REFIID riid
, void** ppvObject
)
2425 IShellLinkImpl
*This
= impl_from_IShellExtInit(iface
);
2426 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObject
);
2430 ShellLink_ExtInit_AddRef( IShellExtInit
* iface
)
2432 IShellLinkImpl
*This
= impl_from_IShellExtInit(iface
);
2433 return IShellLinkA_AddRef((IShellLinkA
*)This
);
2437 ShellLink_ExtInit_Release( IShellExtInit
* iface
)
2439 IShellLinkImpl
*This
= impl_from_IShellExtInit(iface
);
2440 return ShellLink_Release( This
);
2443 /**************************************************************************
2444 * ShellLink implementation of IShellExtInit::Initialize()
2446 * Loads the shelllink from the dataobject the shell is pointing to.
2448 static HRESULT WINAPI
2449 ShellLink_ExtInit_Initialize( IShellExtInit
* iface
, LPCITEMIDLIST pidlFolder
,
2450 IDataObject
*pdtobj
, HKEY hkeyProgID
)
2452 IShellLinkImpl
*This
= impl_from_IShellExtInit(iface
);
2458 TRACE("%p %p %p %p\n", This
, pidlFolder
, pdtobj
, hkeyProgID
);
2463 format
.cfFormat
= CF_HDROP
;
2465 format
.dwAspect
= DVASPECT_CONTENT
;
2467 format
.tymed
= TYMED_HGLOBAL
;
2469 if( FAILED( IDataObject_GetData( pdtobj
, &format
, &stgm
) ) )
2472 count
= DragQueryFileW( stgm
.u
.hGlobal
, -1, NULL
, 0 );
2477 count
= DragQueryFileW( stgm
.u
.hGlobal
, 0, NULL
, 0 );
2479 path
= HeapAlloc( GetProcessHeap(), 0, count
*sizeof(WCHAR
) );
2482 IPersistFile
*pf
= (IPersistFile
*) &This
->lpvtblPersistFile
;
2484 count
= DragQueryFileW( stgm
.u
.hGlobal
, 0, path
, count
);
2485 r
= IPersistFile_Load( pf
, path
, 0 );
2486 HeapFree( GetProcessHeap(), 0, path
);
2489 ReleaseStgMedium( &stgm
);
2494 static const IShellExtInitVtbl eivt
=
2496 ShellLink_ExtInit_QueryInterface
,
2497 ShellLink_ExtInit_AddRef
,
2498 ShellLink_ExtInit_Release
,
2499 ShellLink_ExtInit_Initialize
2502 static HRESULT WINAPI
2503 ShellLink_ContextMenu_QueryInterface( IContextMenu
* iface
, REFIID riid
, void** ppvObject
)
2505 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2506 return IShellLinkA_QueryInterface((IShellLinkA
*)This
, riid
, ppvObject
);
2510 ShellLink_ContextMenu_AddRef( IContextMenu
* iface
)
2512 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2513 return IShellLinkA_AddRef((IShellLinkA
*)This
);
2517 ShellLink_ContextMenu_Release( IContextMenu
* iface
)
2519 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2520 return ShellLink_Release( This
);
2523 static HRESULT WINAPI
2524 ShellLink_QueryContextMenu( IContextMenu
* iface
, HMENU hmenu
, UINT indexMenu
,
2525 UINT idCmdFirst
, UINT idCmdLast
, UINT uFlags
)
2527 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2532 TRACE("%p %p %u %u %u %u\n", This
,
2533 hmenu
, indexMenu
, idCmdFirst
, idCmdLast
, uFlags
);
2536 return E_INVALIDARG
;
2538 if (!LoadStringW(shell32_hInstance
, IDS_OPEN_VERB
, szOpen
, sizeof(szOpen
)/sizeof(WCHAR
)))
2541 szOpen
[(sizeof(szOpen
)/sizeof(WCHAR
))-1] = L
'\0';
2543 memset( &mii
, 0, sizeof(mii
) );
2544 mii
.cbSize
= sizeof (mii
);
2545 mii
.fMask
= MIIM_TYPE
| MIIM_ID
| MIIM_STATE
;
2546 mii
.dwTypeData
= (LPWSTR
)szOpen
;
2547 mii
.cch
= wcslen( mii
.dwTypeData
);
2548 mii
.wID
= idCmdFirst
+ id
++;
2549 mii
.fState
= MFS_DEFAULT
| MFS_ENABLED
;
2550 mii
.fType
= MFT_STRING
;
2551 if (!InsertMenuItemW( hmenu
, indexMenu
, TRUE
, &mii
))
2555 return MAKE_HRESULT( SEVERITY_SUCCESS
, 0, id
);
2559 shelllink_get_msi_component_path( LPWSTR component
)
2564 r
= CommandLineFromMsiDescriptor( component
, NULL
, &sz
);
2565 if (r
!= ERROR_SUCCESS
)
2569 path
= HeapAlloc( GetProcessHeap(), 0, sz
*sizeof(WCHAR
) );
2570 r
= CommandLineFromMsiDescriptor( component
, path
, &sz
);
2571 if (r
!= ERROR_SUCCESS
)
2573 HeapFree( GetProcessHeap(), 0, path
);
2577 TRACE("returning %s\n", debugstr_w( path
) );
2582 INT_PTR CALLBACK
ExtendedShortcutProc(
2596 hDlgCtrl
= GetDlgItem(hwndDlg
, 14000);
2597 SendMessage(hDlgCtrl
, BM_SETCHECK
, BST_CHECKED
, 0);
2601 hDlgCtrl
= GetDlgItem(hwndDlg
, 14000);
2602 if (LOWORD(wParam
) == IDOK
)
2604 if ( SendMessage(hDlgCtrl
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
2605 EndDialog(hwndDlg
, 1);
2607 EndDialog(hwndDlg
, 0);
2609 else if (LOWORD(wParam
) == IDCANCEL
)
2611 EndDialog(hwndDlg
, -1);
2613 else if (LOWORD(wParam
) == 14000)
2615 if ( SendMessage(hDlgCtrl
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
2616 SendMessage(hDlgCtrl
, BM_SETCHECK
, BST_UNCHECKED
, 0);
2618 SendMessage(hDlgCtrl
, BM_SETCHECK
, BST_CHECKED
, 0);
2625 /**************************************************************************
2626 * SH_ShellLinkDlgProc
2628 * dialog proc of the shortcut property dialog
2633 SH_ShellLinkDlgProc(
2640 LPPROPSHEETPAGEW ppsp
;
2642 IShellLinkImpl
*This
;
2644 WCHAR szBuffer
[MAX_PATH
];
2649 This
= (IShellLinkImpl
*)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
2654 ppsp
= (LPPROPSHEETPAGEW
)lParam
;
2658 TRACE("ShellLink_DlgProc (WM_INITDIALOG hwnd %p lParam %p ppsplParam %x)\n",hwndDlg
, lParam
, ppsp
->lParam
);
2660 This
= (IShellLinkImpl
*)ppsp
->lParam
;
2661 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)This
);
2663 TRACE("sArgs: %S sComponent: %S sDescription: %S sIcoPath: %S sPath: %S sPathRel: %S sProduct: %S sWorkDir: %S\n", This
->sArgs
, This
->sComponent
,This
->sDescription
,
2664 This
->sIcoPath
, This
->sPath
, This
->sPathRel
, This
->sProduct
, This
->sWorkDir
);
2667 hDlgCtrl
= GetDlgItem( hwndDlg
, 14009 );
2668 if ( hDlgCtrl
!= NULL
)
2669 SendMessageW( hDlgCtrl
, WM_SETTEXT
, (WPARAM
)NULL
, (LPARAM
)This
->sPath
);
2672 hDlgCtrl
= GetDlgItem( hwndDlg
, 14011 );
2673 if ( hDlgCtrl
!= NULL
)
2674 SendMessageW( hDlgCtrl
, WM_SETTEXT
, (WPARAM
)NULL
, (LPARAM
)This
->sWorkDir
);
2677 hDlgCtrl
= GetDlgItem( hwndDlg
, 14019 );
2678 if ( hDlgCtrl
!= NULL
)
2679 SendMessageW( hDlgCtrl
, WM_SETTEXT
, (WPARAM
)NULL
, (LPARAM
)This
->sDescription
);
2682 lppsn
= (LPPSHNOTIFY
) lParam
;
2683 if ( lppsn
->hdr
.code
== PSN_APPLY
)
2685 /* set working directory */
2686 hDlgCtrl
= GetDlgItem( hwndDlg
, 14011 );
2687 SendMessageW( hDlgCtrl
, WM_GETTEXT
, (WPARAM
)MAX_PATH
, (LPARAM
)szBuffer
);
2688 IShellLinkW_fnSetWorkingDirectory((IShellLinkW
*)&This
->lpvtblw
, szBuffer
);
2689 /* set link destination */
2690 hDlgCtrl
= GetDlgItem( hwndDlg
, 14009 );
2691 SendMessageW( hDlgCtrl
, WM_GETTEXT
, (WPARAM
)MAX_PATH
, (LPARAM
)szBuffer
);
2692 if ( !SHELL_ExistsFileW(szBuffer
) )
2694 //FIXME load localized error msg
2695 MessageBoxW( hwndDlg
, L
"file not existing", szBuffer
, MB_OK
);
2696 SetWindowLongPtr( hwndDlg
, DWL_MSGRESULT
, PSNRET_INVALID_NOCHANGEPAGE
);
2699 ptr
= wcsrchr(szBuffer
, L
'.');
2700 if (ptr
&& !_wcsnicmp(ptr
, L
".lnk", 4))
2702 // FIXME load localized error msg
2703 MessageBoxW( hwndDlg
, L
"You cannot create a link to a shortcut", L
"Error", MB_ICONERROR
);
2704 SetWindowLongPtr( hwndDlg
, DWL_MSGRESULT
, PSNRET_INVALID_NOCHANGEPAGE
);
2708 IShellLinkW_fnSetPath((IShellLinkW
*)&This
->lpvtblw
, szBuffer
);
2710 TRACE("This %p sLinkPath %S\n", This
, This
->sLinkPath
);
2711 IPersistFile_fnSave( (IPersistFile
*)&This
->lpvtblPersistFile
, This
->sLinkPath
, TRUE
);
2712 SetWindowLongPtr( hwndDlg
, DWL_MSGRESULT
, PSNRET_NOERROR
);
2717 switch(LOWORD(wParam
))
2722 /// open target directory
2727 wcscpy(szBuffer
, This
->sIcoPath
);
2729 wcscpy(szBuffer
, This
->sPath
);
2731 IconIndex
= This
->iIcoNdx
;
2732 if (PickIconDlg(hwndDlg
, szBuffer
, MAX_PATH
, &IconIndex
))
2734 IShellLinkW_fnSetIconLocation((IShellLinkW
*)&This
->lpvtblw
, szBuffer
, IconIndex
);
2736 /// FIXME redraw icon
2740 result
= DialogBoxParamW(shell32_hInstance
, MAKEINTRESOURCEW(SHELL_EXTENDED_SHORTCUT_DLG
), hwndDlg
, ExtendedShortcutProc
, (LPARAM
)This
->bRunAs
);
2741 if (result
== 1 || result
== 0)
2743 if ( This
->bRunAs
!= result
)
2745 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
2748 This
->bRunAs
= result
;
2752 switch(HIWORD(wParam
))
2755 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
2765 /**************************************************************************
2766 * ShellLink_IShellPropSheetExt interface
2769 static HRESULT WINAPI
2770 ShellLink_IShellPropSheetExt_QueryInterface( IShellPropSheetExt
* iface
, REFIID riid
, void** ppvObject
)
2772 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2773 return ShellLink_QueryInterface( This
, riid
, ppvObject
);
2777 ShellLink_IShellPropSheetExt_AddRef( IShellPropSheetExt
* iface
)
2779 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2780 return ShellLink_AddRef( This
);
2784 ShellLink_IShellPropSheetExt_Release( IShellPropSheetExt
* iface
)
2786 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2787 return ShellLink_Release( This
);
2790 static HRESULT WINAPI
2791 ShellLink_IShellPropSheetExt_AddPages( IShellPropSheetExt
*iface
, LPFNADDPROPSHEETPAGE pfnAddPage
, LPARAM lParam
)
2793 HPROPSHEETPAGE hPage
;
2795 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2797 hPage
= SH_CreatePropertySheetPage("SHELL_GENERAL_SHORTCUT_DLG", SH_ShellLinkDlgProc
, (LPARAM
)This
, NULL
);
2800 ERR("failed to create property sheet page\n");
2804 bRet
= pfnAddPage(hPage
, lParam
);
2811 static HRESULT WINAPI
2812 ShellLink_IShellPropSheetExt_ReplacePages( IShellPropSheetExt
*iface
, UINT uPageID
, LPFNADDPROPSHEETPAGE pfnReplacePage
, LPARAM lParam
)
2814 IShellLinkImpl
*This
= impl_from_IShellPropSheetExt(iface
);
2815 TRACE("(%p) (uPageID %u, pfnReplacePage %p lParam %p\n", This
, uPageID
, pfnReplacePage
, lParam
);
2819 static const IShellPropSheetExtVtbl pse
=
2821 ShellLink_IShellPropSheetExt_QueryInterface
,
2822 ShellLink_IShellPropSheetExt_AddRef
,
2823 ShellLink_IShellPropSheetExt_Release
,
2824 ShellLink_IShellPropSheetExt_AddPages
,
2825 ShellLink_IShellPropSheetExt_ReplacePages
2828 static HRESULT WINAPI
2829 ShellLink_InvokeCommand( IContextMenu
* iface
, LPCMINVOKECOMMANDINFO lpici
)
2831 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2832 static const WCHAR szOpen
[] = { 'o','p','e','n',0 };
2833 static const WCHAR szCplOpen
[] = { 'c','p','l','o','p','e','n',0 };
2834 SHELLEXECUTEINFOW sei
;
2835 HWND hwnd
= NULL
; /* FIXME: get using interface set from IObjectWithSite */
2840 TRACE("%p %p\n", This
, lpici
);
2842 if ( lpici
->cbSize
< sizeof (CMINVOKECOMMANDINFO
) )
2843 return E_INVALIDARG
;
2845 r
= IShellLinkW_Resolve( (IShellLinkW
*)&(This
->lpvtblw
), hwnd
, 0 );
2848 TRACE("failed to resolve component with error 0x%08x", r
);
2851 if ( This
->sComponent
)
2853 path
= shelllink_get_msi_component_path( This
->sComponent
);
2858 path
= strdupW( This
->sPath
);
2860 if ( lpici
->cbSize
== sizeof (CMINVOKECOMMANDINFOEX
) &&
2861 ( lpici
->fMask
& CMIC_MASK_UNICODE
) )
2863 LPCMINVOKECOMMANDINFOEX iciex
= (LPCMINVOKECOMMANDINFOEX
) lpici
;
2867 len
+= wcslen( This
->sArgs
);
2868 if ( iciex
->lpParametersW
)
2869 len
+= wcslen( iciex
->lpParametersW
);
2871 args
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
) );
2874 wcscat( args
, This
->sArgs
);
2875 if ( iciex
->lpParametersW
)
2877 static const WCHAR space
[] = { ' ', 0 };
2878 wcscat( args
, space
);
2879 wcscat( args
, iciex
->lpParametersW
);
2882 else if (This
->sArgs
!= NULL
)
2884 args
= strdupW( This
->sArgs
);
2887 memset( &sei
, 0, sizeof sei
);
2888 sei
.cbSize
= sizeof sei
;
2889 sei
.fMask
= SEE_MASK_UNICODE
| (lpici
->fMask
& (SEE_MASK_NOASYNC
|SEE_MASK_ASYNCOK
|SEE_MASK_FLAG_NO_UI
));
2891 sei
.nShow
= This
->iShowCmd
;
2892 sei
.lpDirectory
= This
->sWorkDir
;
2893 sei
.lpParameters
= args
;
2894 sei
.lpVerb
= szOpen
;
2896 // HACK for ShellExecuteExW
2897 if (!wcsstr(This
->sPath
, L
".cpl"))
2898 sei
.lpVerb
= szOpen
;
2900 sei
.lpVerb
= szCplOpen
;
2902 if( ShellExecuteExW( &sei
) )
2907 HeapFree( GetProcessHeap(), 0, args
);
2908 HeapFree( GetProcessHeap(), 0, path
);
2913 static HRESULT WINAPI
2914 ShellLink_GetCommandString( IContextMenu
* iface
, UINT_PTR idCmd
, UINT uType
,
2915 UINT
* pwReserved
, LPSTR pszName
, UINT cchMax
)
2917 IShellLinkImpl
*This
= impl_from_IContextMenu(iface
);
2919 FIXME("%p %lu %u %p %p %u\n", This
,
2920 idCmd
, uType
, pwReserved
, pszName
, cchMax
);
2925 static const IContextMenuVtbl cmvt
=
2927 ShellLink_ContextMenu_QueryInterface
,
2928 ShellLink_ContextMenu_AddRef
,
2929 ShellLink_ContextMenu_Release
,
2930 ShellLink_QueryContextMenu
,
2931 ShellLink_InvokeCommand
,
2932 ShellLink_GetCommandString
2935 static HRESULT WINAPI
2936 ShellLink_ObjectWithSite_QueryInterface( IObjectWithSite
* iface
, REFIID riid
, void** ppvObject
)
2938 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2939 return ShellLink_QueryInterface( This
, riid
, ppvObject
);
2943 ShellLink_ObjectWithSite_AddRef( IObjectWithSite
* iface
)
2945 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2946 return ShellLink_AddRef( This
);
2950 ShellLink_ObjectWithSite_Release( IObjectWithSite
* iface
)
2952 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2953 return ShellLink_Release( This
);
2956 static HRESULT WINAPI
2957 ShellLink_GetSite( IObjectWithSite
*iface
, REFIID iid
, void ** ppvSite
)
2959 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2961 TRACE("%p %s %p\n", This
, debugstr_guid( iid
), ppvSite
);
2965 return IUnknown_QueryInterface( This
->site
, iid
, ppvSite
);
2968 static HRESULT WINAPI
2969 ShellLink_SetSite( IObjectWithSite
*iface
, IUnknown
*punk
)
2971 IShellLinkImpl
*This
= impl_from_IObjectWithSite(iface
);
2973 TRACE("%p %p\n", iface
, punk
);
2976 IUnknown_AddRef( punk
);
2982 static const IObjectWithSiteVtbl owsvt
=
2984 ShellLink_ObjectWithSite_QueryInterface
,
2985 ShellLink_ObjectWithSite_AddRef
,
2986 ShellLink_ObjectWithSite_Release
,