3 * Copyright 1997 Marcus Meissner
4 * Copyright 1998 Juergen Schmied
12 #include "wine/obj_base.h"
13 #include "wine/obj_storage.h"
14 #include "wine/obj_shelllink.h"
19 #include "shell32_main.h"
22 DEFAULT_DEBUG_CHANNEL(shell
)
24 /* link file formats */
28 /* lnk elements: simple link has 0x0B */
34 #define MAXIMIZED 0x03
35 #define MINIMIZED 0x07
37 typedef struct _LINK_HEADER
38 { DWORD MagicStr
; /* 0x00 'L','\0','\0','\0' */
39 GUID MagicGuid
; /* 0x04 is CLSID_ShellLink */
40 DWORD Flag1
; /* 0x14 describes elements following */
41 DWORD Flag2
; /* 0x18 */
42 FILETIME Time1
; /* 0x1c */
43 FILETIME Time2
; /* 0x24 */
44 FILETIME Time3
; /* 0x2c */
45 DWORD Unknown1
; /* 0x34 */
46 DWORD Unknown2
; /* 0x38 icon number */
47 DWORD Flag3
; /* 0x3c startup type */
48 DWORD Unknown4
; /* 0x40 hotkey */
49 DWORD Unknown5
; /* 0x44 */
50 DWORD Unknown6
; /* 0x48 */
51 USHORT PidlSize
; /* 0x4c */
52 ITEMIDLIST Pidl
; /* 0x4e */
53 } LINK_HEADER
, * PLINK_HEADER
;
57 /* IPersistFile Implementation */
61 ICOM_VTABLE(IPersistFile
)* lpvtbl
;
68 static struct ICOM_VTABLE(IPersistFile
) pfvt
;
71 /**************************************************************************
72 * IPersistFile_Constructor
74 IPersistFileImpl
* IPersistFile_Constructor(void)
78 sl
= (IPersistFileImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IPersistFileImpl
));
84 TRACE(shell
,"(%p)->()\n",sl
);
89 /**************************************************************************
90 * IPersistFile_QueryInterface
92 static HRESULT WINAPI
IPersistFile_fnQueryInterface(
93 IPersistFile
* iface
, REFIID riid
, LPVOID
*ppvObj
)
95 ICOM_THIS(IPersistFileImpl
,iface
);
98 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
99 TRACE(shell
,"(%p)->(\n\tIID:\t%s)\n",This
,xriid
);
103 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
106 else if(IsEqualIID(riid
, &IID_IPersistFile
)) /*IPersistFile*/
107 { *ppvObj
= (LPPERSISTFILE
)This
;
111 { IPersistFile_AddRef((IPersistFile
*)*ppvObj
);
112 TRACE(shell
,"-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
115 TRACE(shell
,"-- Interface: E_NOINTERFACE\n");
116 return E_NOINTERFACE
;
118 /******************************************************************************
119 * IPersistFile_AddRef
121 static ULONG WINAPI
IPersistFile_fnAddRef(IPersistFile
* iface
)
123 ICOM_THIS(IPersistFileImpl
,iface
);
125 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
128 return ++(This
->ref
);
130 /******************************************************************************
131 * IPersistFile_Release
133 static ULONG WINAPI
IPersistFile_fnRelease(IPersistFile
* iface
)
135 ICOM_THIS(IPersistFileImpl
,iface
);
137 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
142 { TRACE(shell
,"-- destroying IPersistFile(%p)\n",This
);
144 HeapFree(GetProcessHeap(),0,This
->sPath
);
147 HeapFree(GetProcessHeap(),0,This
);
153 static HRESULT WINAPI
IPersistFile_fnGetClassID(const IPersistFile
* iface
, CLSID
*pClassID
)
155 ICOM_CTHIS(IPersistFile
,iface
);
156 FIXME(shell
,"(%p)\n",This
);
159 static HRESULT WINAPI
IPersistFile_fnIsDirty(const IPersistFile
* iface
)
161 ICOM_CTHIS(IPersistFile
,iface
);
162 FIXME(shell
,"(%p)\n",This
);
165 static HRESULT WINAPI
IPersistFile_fnLoad(IPersistFile
* iface
, LPCOLESTR pszFileName
, DWORD dwMode
)
167 ICOM_THIS(IPersistFileImpl
,iface
);
170 LPSTR sFile
= HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName
);
171 HFILE hFile
= OpenFile( sFile
, &ofs
, OF_READ
);
174 HRESULT hRet
= E_FAIL
;
177 TRACE(shell
,"(%p)->(%s)\n",This
,sFile
);
179 HeapFree(GetProcessHeap(),0,sFile
);
181 if ( !(hMapping
= CreateFileMappingA(hFile
,NULL
,PAGE_READONLY
|SEC_COMMIT
,0,0,NULL
)))
182 { WARN(shell
,"failed to create filemap.\n");
186 if ( !(pImage
= (PLINK_HEADER
) MapViewOfFile(hMapping
,FILE_MAP_READ
,0,0,0)))
187 { WARN(shell
,"failed to mmap filemap.\n");
191 if (!( (pImage
->MagicStr
== 0x0000004CL
) && IsEqualIID(&pImage
->MagicGuid
, &CLSID_ShellLink
)))
192 { TRACE(shell
,"file isn't a lnk\n");
196 { /* for debugging */
198 FileTimeToSystemTime (&pImage
->Time1
, &time
);
199 GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&time
, NULL
, sTemp
, 256);
200 TRACE(shell
, "-- time1: %s\n", sTemp
);
202 FileTimeToSystemTime (&pImage
->Time2
, &time
);
203 GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&time
, NULL
, sTemp
, 256);
204 TRACE(shell
, "-- time2: %s\n", sTemp
);
206 FileTimeToSystemTime (&pImage
->Time3
, &time
);
207 GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&time
, NULL
, sTemp
, 256);
208 TRACE(shell
, "-- time3: %s\n", sTemp
);
209 pdump (&pImage
->Pidl
);
212 if (!pcheck (&pImage
->Pidl
))
215 This
->pPidl
= ILClone (&pImage
->Pidl
);
217 _ILGetPidlPath(&pImage
->Pidl
, sTemp
, 512);
218 This
->sPath
= HEAP_strdupA ( GetProcessHeap(), 0, sTemp
);
221 end_3
: UnmapViewOfFile(pImage
);
222 end_2
: CloseHandle(hMapping
);
223 end_1
: _lclose( hFile
);
228 static HRESULT WINAPI
IPersistFile_fnSave(IPersistFile
* iface
, LPCOLESTR pszFileName
, BOOL fRemember
)
230 ICOM_THIS(IPersistFileImpl
,iface
);
231 FIXME(shell
,"(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
234 static HRESULT WINAPI
IPersistFile_fnSaveCompleted(IPersistFile
* iface
, LPCOLESTR pszFileName
)
236 ICOM_THIS(IPersistFileImpl
,iface
);
237 FIXME(shell
,"(%p)->(%s)\n",This
,debugstr_w(pszFileName
));
240 static HRESULT WINAPI
IPersistFile_fnGetCurFile(const IPersistFile
* iface
, LPOLESTR
*ppszFileName
)
242 ICOM_CTHIS(IPersistFileImpl
,iface
);
243 FIXME(shell
,"(%p)\n",This
);
247 static struct ICOM_VTABLE(IPersistFile
) pfvt
=
249 IPersistFile_fnQueryInterface
,
250 IPersistFile_fnAddRef
,
251 IPersistFile_fnRelease
,
252 IPersistFile_fnGetClassID
,
253 IPersistFile_fnIsDirty
,
256 IPersistFile_fnSaveCompleted
,
257 IPersistFile_fnGetCurFile
261 /**************************************************************************
262 * IShellLink's IClassFactory implementation
266 /* IUnknown fields */
267 ICOM_VTABLE(IClassFactory
)* lpvtbl
;
271 static ICOM_VTABLE(IClassFactory
) slcfvt
;
273 /**************************************************************************
274 * IShellLink_CF_Constructor
277 LPCLASSFACTORY
IShellLink_CF_Constructor(void)
279 IClassFactoryImpl
* lpclf
;
281 lpclf
= (IClassFactoryImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl
));
283 lpclf
->lpvtbl
= &slcfvt
;
284 TRACE(shell
,"(%p)->()\n",lpclf
);
286 return (LPCLASSFACTORY
)lpclf
;
288 /**************************************************************************
289 * IShellLink_CF_QueryInterface
291 static HRESULT WINAPI
IShellLink_CF_QueryInterface(
292 IClassFactory
* iface
, REFIID riid
, LPVOID
*ppvObj
)
294 ICOM_THIS(IClassFactoryImpl
,iface
);
296 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
297 TRACE(shell
,"(%p)->(\n\tIID:\t%s)\n",This
,xriid
);
301 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
302 { *ppvObj
= (LPUNKNOWN
)This
;
304 else if(IsEqualIID(riid
, &IID_IClassFactory
)) /*IClassFactory*/
305 { *ppvObj
= (LPCLASSFACTORY
)This
;
309 { IUnknown_AddRef((IUnknown
*)*ppvObj
);
310 TRACE(shell
,"-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
313 TRACE(shell
,"-- Interface: E_NOINTERFACE\n");
314 return E_NOINTERFACE
;
316 /******************************************************************************
317 * IShellLink_CF_AddRef
319 static ULONG WINAPI
IShellLink_CF_AddRef(IClassFactory
* iface
)
321 ICOM_THIS(IClassFactoryImpl
,iface
);
322 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
325 return ++(This
->ref
);
327 /******************************************************************************
328 * IShellLink_CF_Release
330 static ULONG WINAPI
IShellLink_CF_Release(IClassFactory
* iface
)
332 ICOM_THIS(IClassFactoryImpl
,iface
);
333 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
337 { TRACE(shell
,"-- destroying IClassFactory(%p)\n",This
);
338 HeapFree(GetProcessHeap(),0,This
);
343 /******************************************************************************
344 * IShellLink_CF_CreateInstance
346 static HRESULT WINAPI
IShellLink_CF_CreateInstance(
347 IClassFactory
* iface
, LPUNKNOWN pUnknown
, REFIID riid
, LPVOID
*ppObject
)
349 ICOM_THIS(IClassFactoryImpl
,iface
);
350 IUnknown
*pObj
= NULL
;
354 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
355 TRACE(shell
,"%p->(%p,\n\tIID:\t%s,%p)\n",This
,pUnknown
,xriid
,ppObject
);
360 { return(CLASS_E_NOAGGREGATION
);
363 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IShellLink
))
364 { pObj
= (IUnknown
*)IShellLink_Constructor();
367 { ERR(shell
,"unknown IID requested\n\tIID:\t%s\n",xriid
);
368 return(E_NOINTERFACE
);
372 { return(E_OUTOFMEMORY
);
375 hres
= IUnknown_QueryInterface(pObj
,riid
, ppObject
);
376 IUnknown_Release(pObj
);
377 TRACE(shell
,"-- Object created: (%p)->%p\n",This
,*ppObject
);
381 /******************************************************************************
382 * IShellLink_CF_LockServer
384 static HRESULT WINAPI
IShellLink_CF_LockServer(IClassFactory
* iface
, BOOL fLock
)
386 ICOM_THIS(IClassFactoryImpl
,iface
);
387 TRACE(shell
,"%p->(0x%x), not implemented\n",This
, fLock
);
390 static ICOM_VTABLE(IClassFactory
) slcfvt
=
392 IShellLink_CF_QueryInterface
,
393 IShellLink_CF_AddRef
,
394 IShellLink_CF_Release
,
395 IShellLink_CF_CreateInstance
,
396 IShellLink_CF_LockServer
399 /**************************************************************************
400 * IShellLink Implementation
405 ICOM_VTABLE(IShellLink
)* lpvtbl
;
407 IPersistFileImpl
* lppf
;
411 static ICOM_VTABLE(IShellLink
) slvt
;
413 /**************************************************************************
414 * IShellLink_Constructor
416 IShellLink
* IShellLink_Constructor(void)
417 { IShellLinkImpl
* sl
;
419 sl
= (IShellLinkImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLinkImpl
));
423 sl
->lppf
= IPersistFile_Constructor();
425 TRACE(shell
,"(%p)->()\n",sl
);
427 return (IShellLink
*)sl
;
430 /**************************************************************************
431 * IShellLink::QueryInterface
433 static HRESULT WINAPI
IShellLink_fnQueryInterface( IShellLink
* iface
, REFIID riid
, LPVOID
*ppvObj
)
435 ICOM_THIS(IShellLinkImpl
, iface
);
438 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
439 TRACE(shell
,"(%p)->(\n\tIID:\t%s)\n",This
,xriid
);
443 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
446 else if(IsEqualIID(riid
, &IID_IShellLink
)) /*IShellLink*/
447 { *ppvObj
= (IShellLink
*)This
;
449 else if(IsEqualIID(riid
, &IID_IPersistFile
)) /*IPersistFile*/
450 { *ppvObj
= (IPersistFile
*)This
->lppf
;
454 { IShellLink_AddRef((IShellLink
*)*ppvObj
);
455 TRACE(shell
,"-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
458 TRACE(shell
,"-- Interface: E_NOINTERFACE\n");
459 return E_NOINTERFACE
;
461 /******************************************************************************
464 static ULONG WINAPI
IShellLink_fnAddRef(IShellLink
* iface
)
466 ICOM_THIS(IShellLinkImpl
, iface
);
468 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
471 return ++(This
->ref
);
473 /******************************************************************************
476 static ULONG WINAPI
IShellLink_fnRelease(IShellLink
* iface
)
478 ICOM_THIS(IShellLinkImpl
, iface
);
480 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
484 { TRACE(shell
,"-- destroying IShellLink(%p)\n",This
);
485 IPersistFile_Release((IPersistFile
*) This
->lppf
); /* IPersistFile*/
486 HeapFree(GetProcessHeap(),0,This
);
492 static HRESULT WINAPI
IShellLink_fnGetPath(IShellLink
* iface
, LPSTR pszFile
,INT cchMaxPath
, WIN32_FIND_DATAA
*pfd
, DWORD fFlags
)
494 ICOM_THIS(IShellLinkImpl
, iface
);
496 TRACE(shell
,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This
, pszFile
, cchMaxPath
, pfd
, fFlags
);
498 strncpy(pszFile
,This
->lppf
->sPath
, cchMaxPath
);
501 static HRESULT WINAPI
IShellLink_fnGetIDList(IShellLink
* iface
, LPITEMIDLIST
* ppidl
)
503 ICOM_THIS(IShellLinkImpl
, iface
);
505 TRACE(shell
,"(%p)->(ppidl=%p)\n",This
, ppidl
);
507 *ppidl
= ILClone(This
->lppf
->pPidl
);
510 static HRESULT WINAPI
IShellLink_fnSetIDList(IShellLink
* iface
, LPCITEMIDLIST pidl
)
512 ICOM_THIS(IShellLinkImpl
, iface
);
514 TRACE (shell
,"(%p)->(pidl=%p)\n",This
, pidl
);
516 if (This
->lppf
->pPidl
)
517 SHFree(This
->lppf
->pPidl
);
518 This
->lppf
->pPidl
= ILClone (pidl
);
521 static HRESULT WINAPI
IShellLink_fnGetDescription(IShellLink
* iface
, LPSTR pszName
,INT cchMaxName
)
523 ICOM_THIS(IShellLinkImpl
, iface
);
525 FIXME(shell
,"(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
526 strncpy(pszName
,"Description, FIXME",cchMaxName
);
529 static HRESULT WINAPI
IShellLink_fnSetDescription(IShellLink
* iface
, LPCSTR pszName
)
531 ICOM_THIS(IShellLinkImpl
, iface
);
533 FIXME(shell
,"(%p)->(desc=%s)\n",This
, pszName
);
536 static HRESULT WINAPI
IShellLink_fnGetWorkingDirectory(IShellLink
* iface
, LPSTR pszDir
,INT cchMaxPath
)
538 ICOM_THIS(IShellLinkImpl
, iface
);
540 FIXME(shell
,"(%p)->()\n",This
);
541 strncpy(pszDir
,"c:\\", cchMaxPath
);
544 static HRESULT WINAPI
IShellLink_fnSetWorkingDirectory(IShellLink
* iface
, LPCSTR pszDir
)
546 ICOM_THIS(IShellLinkImpl
, iface
);
548 FIXME(shell
,"(%p)->(dir=%s)\n",This
, pszDir
);
551 static HRESULT WINAPI
IShellLink_fnGetArguments(IShellLink
* iface
, LPSTR pszArgs
,INT cchMaxPath
)
553 ICOM_THIS(IShellLinkImpl
, iface
);
555 FIXME(shell
,"(%p)->(%p len=%u)\n",This
, pszArgs
, cchMaxPath
);
556 strncpy(pszArgs
, "", cchMaxPath
);
559 static HRESULT WINAPI
IShellLink_fnSetArguments(IShellLink
* iface
, LPCSTR pszArgs
)
561 ICOM_THIS(IShellLinkImpl
, iface
);
563 FIXME(shell
,"(%p)->(args=%s)\n",This
, pszArgs
);
566 static HRESULT WINAPI
IShellLink_fnGetHotkey(IShellLink
* iface
, WORD
*pwHotkey
)
568 ICOM_THIS(IShellLinkImpl
, iface
);
570 FIXME(shell
,"(%p)->(%p) returning 0\n",This
, pwHotkey
);
574 static HRESULT WINAPI
IShellLink_fnSetHotkey(IShellLink
* iface
, WORD wHotkey
)
576 ICOM_THIS(IShellLinkImpl
, iface
);
578 FIXME(shell
,"(%p)->(hotkey=%x)\n",This
, wHotkey
);
581 static HRESULT WINAPI
IShellLink_fnGetShowCmd(IShellLink
* iface
, INT
*piShowCmd
)
583 ICOM_THIS(IShellLinkImpl
, iface
);
585 FIXME(shell
,"(%p)->(%p)\n",This
, piShowCmd
);
589 static HRESULT WINAPI
IShellLink_fnSetShowCmd(IShellLink
* iface
, INT iShowCmd
)
591 ICOM_THIS(IShellLinkImpl
, iface
);
593 FIXME(shell
,"(%p)->(showcmd=%x)\n",This
, iShowCmd
);
596 static HRESULT WINAPI
IShellLink_fnGetIconLocation(IShellLink
* iface
, LPSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
598 ICOM_THIS(IShellLinkImpl
, iface
);
600 FIXME(shell
,"(%p)->(%p len=%u iicon=%p)\n",This
, pszIconPath
, cchIconPath
, piIcon
);
601 strncpy(pszIconPath
,"shell32.dll",cchIconPath
);
605 static HRESULT WINAPI
IShellLink_fnSetIconLocation(IShellLink
* iface
, LPCSTR pszIconPath
,INT iIcon
)
607 ICOM_THIS(IShellLinkImpl
, iface
);
609 FIXME(shell
,"(%p)->(path=%s iicon=%u)\n",This
, pszIconPath
, iIcon
);
612 static HRESULT WINAPI
IShellLink_fnSetRelativePath(IShellLink
* iface
, LPCSTR pszPathRel
, DWORD dwReserved
)
614 ICOM_THIS(IShellLinkImpl
, iface
);
616 FIXME(shell
,"(%p)->(path=%s %lx)\n",This
, pszPathRel
, dwReserved
);
619 static HRESULT WINAPI
IShellLink_fnResolve(IShellLink
* iface
, HWND hwnd
, DWORD fFlags
)
621 ICOM_THIS(IShellLinkImpl
, iface
);
623 FIXME(shell
,"(%p)->(hwnd=%x flags=%lx)\n",This
, hwnd
, fFlags
);
626 static HRESULT WINAPI
IShellLink_fnSetPath(IShellLink
* iface
, LPCSTR pszFile
)
628 ICOM_THIS(IShellLinkImpl
, iface
);
630 FIXME(shell
,"(%p)->(path=%s)\n",This
, pszFile
);
634 /**************************************************************************
635 * IShellLink Implementation
638 static ICOM_VTABLE(IShellLink
) slvt
=
639 { IShellLink_fnQueryInterface
,
641 IShellLink_fnRelease
,
642 IShellLink_fnGetPath
,
643 IShellLink_fnGetIDList
,
644 IShellLink_fnSetIDList
,
645 IShellLink_fnGetDescription
,
646 IShellLink_fnSetDescription
,
647 IShellLink_fnGetWorkingDirectory
,
648 IShellLink_fnSetWorkingDirectory
,
649 IShellLink_fnGetArguments
,
650 IShellLink_fnSetArguments
,
651 IShellLink_fnGetHotkey
,
652 IShellLink_fnSetHotkey
,
653 IShellLink_fnGetShowCmd
,
654 IShellLink_fnSetShowCmd
,
655 IShellLink_fnGetIconLocation
,
656 IShellLink_fnSetIconLocation
,
657 IShellLink_fnSetRelativePath
,
658 IShellLink_fnResolve
,
662 /**************************************************************************
663 * IShellLink's IClassFactory implementation
666 static ICOM_VTABLE(IClassFactory
) slwcfvt
;
668 /**************************************************************************
669 * IShellLinkW_CF_Constructor
672 LPCLASSFACTORY
IShellLinkW_CF_Constructor(void)
674 IClassFactoryImpl
* lpclf
;
676 lpclf
= (IClassFactoryImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl
));
678 lpclf
->lpvtbl
= &slwcfvt
;
679 TRACE(shell
,"(%p)->()\n",lpclf
);
681 return (LPCLASSFACTORY
)lpclf
;
683 /**************************************************************************
684 * IShellLinkW_CF_QueryInterface
686 static HRESULT WINAPI
IShellLinkW_CF_QueryInterface(
687 LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppvObj
)
689 ICOM_THIS(IClassFactoryImpl
,iface
);
691 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
692 TRACE(shell
,"(%p)->(\n\tIID:\t%s)\n",This
,xriid
);
696 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
697 { *ppvObj
= (LPUNKNOWN
)This
;
699 else if(IsEqualIID(riid
, &IID_IClassFactory
)) /*IClassFactory*/
700 { *ppvObj
= (LPCLASSFACTORY
)This
;
704 IUnknown_AddRef((IUnknown
*)*ppvObj
);
705 TRACE(shell
,"-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
708 TRACE(shell
,"-- Interface: E_NOINTERFACE\n");
709 return E_NOINTERFACE
;
711 /******************************************************************************
712 * IShellLinkW_CF_AddRef
714 static ULONG WINAPI
IShellLinkW_CF_AddRef(LPCLASSFACTORY iface
)
716 ICOM_THIS(IClassFactoryImpl
,iface
);
717 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
720 return ++(This
->ref
);
722 /******************************************************************************
723 * IShellLinkW_CF_Release
725 static ULONG WINAPI
IShellLinkW_CF_Release(LPCLASSFACTORY iface
)
727 ICOM_THIS(IClassFactoryImpl
,iface
);
728 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
732 { TRACE(shell
,"-- destroying IClassFactory(%p)\n",This
);
733 HeapFree(GetProcessHeap(),0,This
);
738 /******************************************************************************
739 * IShellLinkW_CF_CreateInstance
741 static HRESULT WINAPI
IShellLinkW_CF_CreateInstance(
742 LPCLASSFACTORY iface
, LPUNKNOWN pUnknown
, REFIID riid
, LPVOID
*ppObject
)
744 ICOM_THIS(IClassFactoryImpl
,iface
);
745 IUnknown
*pObj
= NULL
;
749 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
750 TRACE(shell
,"%p->(%p,\n\tIID:\t%s,%p)\n",This
,pUnknown
,xriid
,ppObject
);
755 { return(CLASS_E_NOAGGREGATION
);
758 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IShellLinkW
))
759 { pObj
= (IUnknown
*)IShellLinkW_Constructor();
762 { ERR(shell
,"unknown IID requested\n\tIID:\t%s\n",xriid
);
763 return(E_NOINTERFACE
);
767 { return(E_OUTOFMEMORY
);
770 hres
= pObj
->lpvtbl
->fnQueryInterface(pObj
,riid
, ppObject
);
771 pObj
->lpvtbl
->fnRelease(pObj
);
772 TRACE(shell
,"-- Object created: (%p)->%p\n",This
,*ppObject
);
776 /******************************************************************************
777 * IShellLinkW_CF_LockServer
780 static HRESULT WINAPI
IShellLinkW_CF_LockServer(LPCLASSFACTORY iface
, BOOL fLock
)
782 ICOM_THIS(IClassFactoryImpl
,iface
);
783 TRACE(shell
,"%p->(0x%x), not implemented\n",This
, fLock
);
787 static ICOM_VTABLE(IClassFactory
) slwcfvt
=
789 IShellLinkW_CF_QueryInterface
,
790 IShellLinkW_CF_AddRef
,
791 IShellLinkW_CF_Release
,
792 IShellLinkW_CF_CreateInstance
,
793 IShellLinkW_CF_LockServer
797 /**************************************************************************
798 * IShellLink Implementation
803 ICOM_VTABLE(IShellLinkW
)* lpvtbl
;
805 IPersistFileImpl
* lppf
;
809 static ICOM_VTABLE(IShellLinkW
) slvtw
;
811 /**************************************************************************
812 * IShellLinkW_fnConstructor
814 IShellLinkW
* IShellLinkW_Constructor(void)
815 { IShellLinkWImpl
* sl
;
817 sl
= (IShellLinkWImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLinkWImpl
));
821 sl
->lppf
= IPersistFile_Constructor();
823 TRACE(shell
,"(%p)->()\n",sl
);
825 return (IShellLinkW
*)sl
;
828 /**************************************************************************
829 * IShellLinkW_fnQueryInterface
831 static HRESULT WINAPI
IShellLinkW_fnQueryInterface(
832 IShellLinkW
* iface
, REFIID riid
, LPVOID
*ppvObj
)
834 ICOM_THIS(IShellLinkWImpl
, iface
);
837 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
838 TRACE(shell
,"(%p)->(\n\tIID:\t%s)\n",This
,xriid
);
842 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
845 else if(IsEqualIID(riid
, &IID_IShellLinkW
)) /*IShellLinkW*/
846 { *ppvObj
= (IShellLinkW
*)This
;
848 else if(IsEqualIID(riid
, &IID_IPersistFile
)) /*IPersistFile*/
849 { *ppvObj
= (IPersistFile
*)This
->lppf
;
853 { IShellLink_AddRef((IShellLinkW
*)*ppvObj
);
854 TRACE(shell
,"-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
858 TRACE(shell
,"-- Interface: E_NOINTERFACE\n");
860 return E_NOINTERFACE
;
862 /******************************************************************************
863 * IShellLinkW_fnAddRef
865 static ULONG WINAPI
IShellLinkW_fnAddRef(IShellLinkW
* iface
)
867 ICOM_THIS(IShellLinkWImpl
, iface
);
869 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
872 return ++(This
->ref
);
874 /******************************************************************************
875 * IShellLinkW_fnRelease
878 static ULONG WINAPI
IShellLinkW_fnRelease(IShellLinkW
* iface
)
880 ICOM_THIS(IShellLinkWImpl
, iface
);
882 TRACE(shell
,"(%p)->(count=%lu)\n",This
,This
->ref
);
886 { TRACE(shell
,"-- destroying IShellLinkW(%p)\n",This
);
887 IPersistFile_Release((IPersistFile
*)This
->lppf
); /* IPersistFile*/
888 HeapFree(GetProcessHeap(),0,This
);
894 static HRESULT WINAPI
IShellLinkW_fnGetPath(IShellLinkW
* iface
, LPWSTR pszFile
,INT cchMaxPath
, WIN32_FIND_DATAA
*pfd
, DWORD fFlags
)
896 ICOM_THIS(IShellLinkWImpl
, iface
);
898 FIXME(shell
,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This
, pszFile
, cchMaxPath
, pfd
, fFlags
);
899 lstrcpynAtoW(pszFile
,"c:\\foo.bar", cchMaxPath
);
903 static HRESULT WINAPI
IShellLinkW_fnGetIDList(IShellLinkW
* iface
, LPITEMIDLIST
* ppidl
)
905 ICOM_THIS(IShellLinkWImpl
, iface
);
907 FIXME(shell
,"(%p)->(ppidl=%p)\n",This
, ppidl
);
908 *ppidl
= _ILCreateDesktop();
912 static HRESULT WINAPI
IShellLinkW_fnSetIDList(IShellLinkW
* iface
, LPCITEMIDLIST pidl
)
914 ICOM_THIS(IShellLinkWImpl
, iface
);
916 FIXME(shell
,"(%p)->(pidl=%p)\n",This
, pidl
);
920 static HRESULT WINAPI
IShellLinkW_fnGetDescription(IShellLinkW
* iface
, LPWSTR pszName
,INT cchMaxName
)
922 ICOM_THIS(IShellLinkWImpl
, iface
);
924 FIXME(shell
,"(%p)->(%p len=%u)\n",This
, pszName
, cchMaxName
);
925 lstrcpynAtoW(pszName
,"Description, FIXME",cchMaxName
);
929 static HRESULT WINAPI
IShellLinkW_fnSetDescription(IShellLinkW
* iface
, LPCWSTR pszName
)
931 ICOM_THIS(IShellLinkWImpl
, iface
);
933 FIXME(shell
,"(%p)->(desc=%s)\n",This
, debugstr_w(pszName
));
937 static HRESULT WINAPI
IShellLinkW_fnGetWorkingDirectory(IShellLinkW
* iface
, LPWSTR pszDir
,INT cchMaxPath
)
939 ICOM_THIS(IShellLinkWImpl
, iface
);
941 FIXME(shell
,"(%p)->()\n",This
);
942 lstrcpynAtoW(pszDir
,"c:\\", cchMaxPath
);
946 static HRESULT WINAPI
IShellLinkW_fnSetWorkingDirectory(IShellLinkW
* iface
, LPCWSTR pszDir
)
948 ICOM_THIS(IShellLinkWImpl
, iface
);
950 FIXME(shell
,"(%p)->(dir=%s)\n",This
, debugstr_w(pszDir
));
954 static HRESULT WINAPI
IShellLinkW_fnGetArguments(IShellLinkW
* iface
, LPWSTR pszArgs
,INT cchMaxPath
)
956 ICOM_THIS(IShellLinkWImpl
, iface
);
958 FIXME(shell
,"(%p)->(%p len=%u)\n",This
, pszArgs
, cchMaxPath
);
959 lstrcpynAtoW(pszArgs
, "", cchMaxPath
);
963 static HRESULT WINAPI
IShellLinkW_fnSetArguments(IShellLinkW
* iface
, LPCWSTR pszArgs
)
965 ICOM_THIS(IShellLinkWImpl
, iface
);
967 FIXME(shell
,"(%p)->(args=%s)\n",This
, debugstr_w(pszArgs
));
971 static HRESULT WINAPI
IShellLinkW_fnGetHotkey(IShellLinkW
* iface
, WORD
*pwHotkey
)
973 ICOM_THIS(IShellLinkWImpl
, iface
);
975 FIXME(shell
,"(%p)->(%p)\n",This
, pwHotkey
);
980 static HRESULT WINAPI
IShellLinkW_fnSetHotkey(IShellLinkW
* iface
, WORD wHotkey
)
982 ICOM_THIS(IShellLinkWImpl
, iface
);
984 FIXME(shell
,"(%p)->(hotkey=%x)\n",This
, wHotkey
);
988 static HRESULT WINAPI
IShellLinkW_fnGetShowCmd(IShellLinkW
* iface
, INT
*piShowCmd
)
990 ICOM_THIS(IShellLinkWImpl
, iface
);
992 FIXME(shell
,"(%p)->(%p)\n",This
, piShowCmd
);
997 static HRESULT WINAPI
IShellLinkW_fnSetShowCmd(IShellLinkW
* iface
, INT iShowCmd
)
999 ICOM_THIS(IShellLinkWImpl
, iface
);
1001 FIXME(shell
,"(%p)->(showcmd=%x)\n",This
, iShowCmd
);
1005 static HRESULT WINAPI
IShellLinkW_fnGetIconLocation(IShellLinkW
* iface
, LPWSTR pszIconPath
,INT cchIconPath
,INT
*piIcon
)
1007 ICOM_THIS(IShellLinkWImpl
, iface
);
1009 FIXME(shell
,"(%p)->(%p len=%u iicon=%p)\n",This
, pszIconPath
, cchIconPath
, piIcon
);
1010 lstrcpynAtoW(pszIconPath
,"shell32.dll",cchIconPath
);
1015 static HRESULT WINAPI
IShellLinkW_fnSetIconLocation(IShellLinkW
* iface
, LPCWSTR pszIconPath
,INT iIcon
)
1017 ICOM_THIS(IShellLinkWImpl
, iface
);
1019 FIXME(shell
,"(%p)->(path=%s iicon=%u)\n",This
, debugstr_w(pszIconPath
), iIcon
);
1023 static HRESULT WINAPI
IShellLinkW_fnSetRelativePath(IShellLinkW
* iface
, LPCWSTR pszPathRel
, DWORD dwReserved
)
1025 ICOM_THIS(IShellLinkWImpl
, iface
);
1027 FIXME(shell
,"(%p)->(path=%s %lx)\n",This
, debugstr_w(pszPathRel
), dwReserved
);
1031 static HRESULT WINAPI
IShellLinkW_fnResolve(IShellLinkW
* iface
, HWND hwnd
, DWORD fFlags
)
1033 ICOM_THIS(IShellLinkWImpl
, iface
);
1035 FIXME(shell
,"(%p)->(hwnd=%x flags=%lx)\n",This
, hwnd
, fFlags
);
1039 static HRESULT WINAPI
IShellLinkW_fnSetPath(IShellLinkW
* iface
, LPCWSTR pszFile
)
1041 ICOM_THIS(IShellLinkWImpl
, iface
);
1043 FIXME(shell
,"(%p)->(path=%s)\n",This
, debugstr_w(pszFile
));
1047 /**************************************************************************
1048 * IShellLinkW Implementation
1051 static ICOM_VTABLE(IShellLinkW
) slvtw
=
1052 { IShellLinkW_fnQueryInterface
,
1053 IShellLinkW_fnAddRef
,
1054 IShellLinkW_fnRelease
,
1055 IShellLinkW_fnGetPath
,
1056 IShellLinkW_fnGetIDList
,
1057 IShellLinkW_fnSetIDList
,
1058 IShellLinkW_fnGetDescription
,
1059 IShellLinkW_fnSetDescription
,
1060 IShellLinkW_fnGetWorkingDirectory
,
1061 IShellLinkW_fnSetWorkingDirectory
,
1062 IShellLinkW_fnGetArguments
,
1063 IShellLinkW_fnSetArguments
,
1064 IShellLinkW_fnGetHotkey
,
1065 IShellLinkW_fnSetHotkey
,
1066 IShellLinkW_fnGetShowCmd
,
1067 IShellLinkW_fnSetShowCmd
,
1068 IShellLinkW_fnGetIconLocation
,
1069 IShellLinkW_fnSetIconLocation
,
1070 IShellLinkW_fnSetRelativePath
,
1071 IShellLinkW_fnResolve
,
1072 IShellLinkW_fnSetPath