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 /* link file formats */
26 /* lnk elements: simple link has 0x0B */
32 #define MAXIMIZED 0x03
33 #define MINIMIZED 0x07
35 typedef struct _LINK_HEADER
36 { DWORD MagicStr; /* 0x00 'L','\0','\0','\0' */
37 GUID MagicGuid; /* 0x04 is CLSID_ShellLink */
38 DWORD Flag1; /* 0x14 describes elements following */
39 DWORD Flag2; /* 0x18 */
40 FILETIME Time1; /* 0x1c */
41 FILETIME Time2; /* 0x24 */
42 FILETIME Time3; /* 0x2c */
43 DWORD Unknown1; /* 0x34 */
44 DWORD Unknown2; /* 0x38 icon number */
45 DWORD Flag3; /* 0x3c startup type */
46 DWORD Unknown4; /* 0x40 hotkey */
47 DWORD Unknown5; /* 0x44 */
48 DWORD Unknown6; /* 0x48 */
49 USHORT PidlSize; /* 0x4c */
50 ITEMIDLIST Pidl; /* 0x4e */
51 } LINK_HEADER, * PLINK_HEADER;
55 /* IPersistFile Implementation */
59 ICOM_VTABLE(IPersistFile)* lpvtbl;
66 static struct ICOM_VTABLE(IPersistFile) pfvt;
69 /**************************************************************************
70 * IPersistFile_Constructor
72 IPersistFileImpl * IPersistFile_Constructor(void)
76 sl = (IPersistFileImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IPersistFileImpl));
82 TRACE(shell,"(%p)->()\n",sl);
87 /**************************************************************************
88 * IPersistFile_QueryInterface
90 static HRESULT WINAPI IPersistFile_fnQueryInterface(
91 IPersistFile* iface, REFIID riid, LPVOID *ppvObj)
93 ICOM_THIS(IPersistFileImpl,iface);
96 WINE_StringFromCLSID((LPCLSID)riid,xriid);
97 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
101 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
104 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
105 { *ppvObj = (LPPERSISTFILE)This;
109 { IPersistFile_AddRef((IPersistFile*)*ppvObj);
110 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
113 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
114 return E_NOINTERFACE;
116 /******************************************************************************
117 * IPersistFile_AddRef
119 static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile* iface)
121 ICOM_THIS(IPersistFileImpl,iface);
123 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
126 return ++(This->ref);
128 /******************************************************************************
129 * IPersistFile_Release
131 static ULONG WINAPI IPersistFile_fnRelease(IPersistFile* iface)
133 ICOM_THIS(IPersistFileImpl,iface);
135 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
140 { TRACE(shell,"-- destroying IPersistFile(%p)\n",This);
142 HeapFree(GetProcessHeap(),0,This->sPath);
145 HeapFree(GetProcessHeap(),0,This);
151 static HRESULT WINAPI IPersistFile_fnGetClassID(const IPersistFile* iface, CLSID *pClassID)
153 ICOM_CTHIS(IPersistFile,iface);
154 FIXME(shell,"(%p)\n",This);
157 static HRESULT WINAPI IPersistFile_fnIsDirty(const IPersistFile* iface)
159 ICOM_CTHIS(IPersistFile,iface);
160 FIXME(shell,"(%p)\n",This);
163 static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
165 ICOM_THIS(IPersistFileImpl,iface);
168 LPSTR sFile = HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName);
169 HFILE hFile = OpenFile( sFile, &ofs, OF_READ );
172 HRESULT hRet = E_FAIL;
175 TRACE(shell,"(%p)->(%s)\n",This,sFile);
177 HeapFree(GetProcessHeap(),0,sFile);
179 if ( !(hMapping = CreateFileMappingA(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL)))
180 { WARN(shell,"failed to create filemap.\n");
184 if ( !(pImage = (PLINK_HEADER) MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0)))
185 { WARN(shell,"failed to mmap filemap.\n");
189 if (!( (pImage->MagicStr == 0x0000004CL) && IsEqualIID(&pImage->MagicGuid, &CLSID_ShellLink)))
190 { TRACE(shell,"file isn't a lnk\n");
194 { /* for debugging */
196 FileTimeToSystemTime (&pImage->Time1, &time);
197 GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, sTemp, 256);
198 TRACE(shell, "-- time1: %s\n", sTemp);
200 FileTimeToSystemTime (&pImage->Time2, &time);
201 GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, sTemp, 256);
202 TRACE(shell, "-- time2: %s\n", sTemp);
204 FileTimeToSystemTime (&pImage->Time3, &time);
205 GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, sTemp, 256);
206 TRACE(shell, "-- time3: %s\n", sTemp);
207 pdump (&pImage->Pidl);
210 This->pPidl = ILClone (&pImage->Pidl);
212 _ILGetPidlPath(&pImage->Pidl, sTemp, 512);
213 This->sPath = HEAP_strdupA ( GetProcessHeap(), 0, sTemp);
216 end_3: UnmapViewOfFile(pImage);
217 end_2: CloseHandle(hMapping);
218 end_1: _lclose( hFile);
223 static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
225 ICOM_THIS(IPersistFileImpl,iface);
226 FIXME(shell,"(%p)->(%s)\n",This,debugstr_w(pszFileName));
229 static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
231 ICOM_THIS(IPersistFileImpl,iface);
232 FIXME(shell,"(%p)->(%s)\n",This,debugstr_w(pszFileName));
235 static HRESULT WINAPI IPersistFile_fnGetCurFile(const IPersistFile* iface, LPOLESTR *ppszFileName)
237 ICOM_CTHIS(IPersistFileImpl,iface);
238 FIXME(shell,"(%p)\n",This);
242 static struct ICOM_VTABLE(IPersistFile) pfvt =
244 IPersistFile_fnQueryInterface,
245 IPersistFile_fnAddRef,
246 IPersistFile_fnRelease,
247 IPersistFile_fnGetClassID,
248 IPersistFile_fnIsDirty,
251 IPersistFile_fnSaveCompleted,
252 IPersistFile_fnGetCurFile
256 /**************************************************************************
257 * IShellLink's IClassFactory implementation
261 /* IUnknown fields */
262 ICOM_VTABLE(IClassFactory)* lpvtbl;
266 static ICOM_VTABLE(IClassFactory) slcfvt;
268 /**************************************************************************
269 * IShellLink_CF_Constructor
272 LPCLASSFACTORY IShellLink_CF_Constructor(void)
274 IClassFactoryImpl* lpclf;
276 lpclf= (IClassFactoryImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl));
278 lpclf->lpvtbl = &slcfvt;
279 TRACE(shell,"(%p)->()\n",lpclf);
281 return (LPCLASSFACTORY)lpclf;
283 /**************************************************************************
284 * IShellLink_CF_QueryInterface
286 static HRESULT WINAPI IShellLink_CF_QueryInterface(
287 IClassFactory* iface, REFIID riid, LPVOID *ppvObj)
289 ICOM_THIS(IClassFactoryImpl,iface);
291 WINE_StringFromCLSID((LPCLSID)riid,xriid);
292 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
296 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
297 { *ppvObj = (LPUNKNOWN)This;
299 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
300 { *ppvObj = (LPCLASSFACTORY)This;
304 { IUnknown_AddRef((IUnknown*)*ppvObj);
305 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
308 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
309 return E_NOINTERFACE;
311 /******************************************************************************
312 * IShellLink_CF_AddRef
314 static ULONG WINAPI IShellLink_CF_AddRef(IClassFactory* iface)
316 ICOM_THIS(IClassFactoryImpl,iface);
317 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
320 return ++(This->ref);
322 /******************************************************************************
323 * IShellLink_CF_Release
325 static ULONG WINAPI IShellLink_CF_Release(IClassFactory* iface)
327 ICOM_THIS(IClassFactoryImpl,iface);
328 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
332 { TRACE(shell,"-- destroying IClassFactory(%p)\n",This);
333 HeapFree(GetProcessHeap(),0,This);
338 /******************************************************************************
339 * IShellLink_CF_CreateInstance
341 static HRESULT WINAPI IShellLink_CF_CreateInstance(
342 IClassFactory* iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
344 ICOM_THIS(IClassFactoryImpl,iface);
345 IUnknown *pObj = NULL;
349 WINE_StringFromCLSID((LPCLSID)riid,xriid);
350 TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,xriid,ppObject);
355 { return(CLASS_E_NOAGGREGATION);
358 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLink))
359 { pObj = (IUnknown *)IShellLink_Constructor();
362 { ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
363 return(E_NOINTERFACE);
367 { return(E_OUTOFMEMORY);
370 hres = IUnknown_QueryInterface(pObj,riid, ppObject);
371 IUnknown_Release(pObj);
372 TRACE(shell,"-- Object created: (%p)->%p\n",This,*ppObject);
376 /******************************************************************************
377 * IShellLink_CF_LockServer
379 static HRESULT WINAPI IShellLink_CF_LockServer(IClassFactory* iface, BOOL fLock)
381 ICOM_THIS(IClassFactoryImpl,iface);
382 TRACE(shell,"%p->(0x%x), not implemented\n",This, fLock);
385 static ICOM_VTABLE(IClassFactory) slcfvt =
387 IShellLink_CF_QueryInterface,
388 IShellLink_CF_AddRef,
389 IShellLink_CF_Release,
390 IShellLink_CF_CreateInstance,
391 IShellLink_CF_LockServer
394 /**************************************************************************
395 * IShellLink Implementation
400 ICOM_VTABLE(IShellLink)* lpvtbl;
402 IPersistFileImpl* lppf;
406 static ICOM_VTABLE(IShellLink) slvt;
408 /**************************************************************************
409 * IShellLink_Constructor
411 IShellLink * IShellLink_Constructor(void)
412 { IShellLinkImpl * sl;
414 sl = (IShellLinkImpl *)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLinkImpl));
418 sl->lppf = IPersistFile_Constructor();
420 TRACE(shell,"(%p)->()\n",sl);
422 return (IShellLink *)sl;
425 /**************************************************************************
426 * IShellLink::QueryInterface
428 static HRESULT WINAPI IShellLink_fnQueryInterface( IShellLink * iface, REFIID riid, LPVOID *ppvObj)
430 ICOM_THIS(IShellLinkImpl, iface);
433 WINE_StringFromCLSID((LPCLSID)riid,xriid);
434 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
438 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
441 else if(IsEqualIID(riid, &IID_IShellLink)) /*IShellLink*/
442 { *ppvObj = (IShellLink *)This;
444 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
445 { *ppvObj = (IPersistFile *)This->lppf;
449 { IShellLink_AddRef((IShellLink*)*ppvObj);
450 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
453 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
454 return E_NOINTERFACE;
456 /******************************************************************************
459 static ULONG WINAPI IShellLink_fnAddRef(IShellLink * iface)
461 ICOM_THIS(IShellLinkImpl, iface);
463 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
466 return ++(This->ref);
468 /******************************************************************************
471 static ULONG WINAPI IShellLink_fnRelease(IShellLink * iface)
473 ICOM_THIS(IShellLinkImpl, iface);
475 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
479 { TRACE(shell,"-- destroying IShellLink(%p)\n",This);
480 IPersistFile_Release((IPersistFile*) This->lppf); /* IPersistFile*/
481 HeapFree(GetProcessHeap(),0,This);
487 static HRESULT WINAPI IShellLink_fnGetPath(IShellLink * iface, LPSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
489 ICOM_THIS(IShellLinkImpl, iface);
491 TRACE(shell,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
493 strncpy(pszFile,This->lppf->sPath, cchMaxPath);
496 static HRESULT WINAPI IShellLink_fnGetIDList(IShellLink * iface, LPITEMIDLIST * ppidl)
498 ICOM_THIS(IShellLinkImpl, iface);
500 TRACE(shell,"(%p)->(ppidl=%p)\n",This, ppidl);
502 *ppidl = ILClone(This->lppf->pPidl);
505 static HRESULT WINAPI IShellLink_fnSetIDList(IShellLink * iface, LPCITEMIDLIST pidl)
507 ICOM_THIS(IShellLinkImpl, iface);
509 TRACE (shell,"(%p)->(pidl=%p)\n",This, pidl);
511 if (This->lppf->pPidl)
512 SHFree(This->lppf->pPidl);
513 This->lppf->pPidl = ILClone (pidl);
516 static HRESULT WINAPI IShellLink_fnGetDescription(IShellLink * iface, LPSTR pszName,INT cchMaxName)
518 ICOM_THIS(IShellLinkImpl, iface);
520 FIXME(shell,"(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
521 strncpy(pszName,"Description, FIXME",cchMaxName);
524 static HRESULT WINAPI IShellLink_fnSetDescription(IShellLink * iface, LPCSTR pszName)
526 ICOM_THIS(IShellLinkImpl, iface);
528 FIXME(shell,"(%p)->(desc=%s)\n",This, pszName);
531 static HRESULT WINAPI IShellLink_fnGetWorkingDirectory(IShellLink * iface, LPSTR pszDir,INT cchMaxPath)
533 ICOM_THIS(IShellLinkImpl, iface);
535 FIXME(shell,"(%p)->()\n",This);
536 strncpy(pszDir,"c:\\", cchMaxPath);
539 static HRESULT WINAPI IShellLink_fnSetWorkingDirectory(IShellLink * iface, LPCSTR pszDir)
541 ICOM_THIS(IShellLinkImpl, iface);
543 FIXME(shell,"(%p)->(dir=%s)\n",This, pszDir);
546 static HRESULT WINAPI IShellLink_fnGetArguments(IShellLink * iface, LPSTR pszArgs,INT cchMaxPath)
548 ICOM_THIS(IShellLinkImpl, iface);
550 FIXME(shell,"(%p)->(%p len=%u)\n",This, pszArgs, cchMaxPath);
551 strncpy(pszArgs, "", cchMaxPath);
554 static HRESULT WINAPI IShellLink_fnSetArguments(IShellLink * iface, LPCSTR pszArgs)
556 ICOM_THIS(IShellLinkImpl, iface);
558 FIXME(shell,"(%p)->(args=%s)\n",This, pszArgs);
561 static HRESULT WINAPI IShellLink_fnGetHotkey(IShellLink * iface, WORD *pwHotkey)
563 ICOM_THIS(IShellLinkImpl, iface);
565 FIXME(shell,"(%p)->(%p)\n",This, pwHotkey);
569 static HRESULT WINAPI IShellLink_fnSetHotkey(IShellLink * iface, WORD wHotkey)
571 ICOM_THIS(IShellLinkImpl, iface);
573 FIXME(shell,"(%p)->(hotkey=%x)\n",This, wHotkey);
576 static HRESULT WINAPI IShellLink_fnGetShowCmd(IShellLink * iface, INT *piShowCmd)
578 ICOM_THIS(IShellLinkImpl, iface);
580 FIXME(shell,"(%p)->(%p)\n",This, piShowCmd);
584 static HRESULT WINAPI IShellLink_fnSetShowCmd(IShellLink * iface, INT iShowCmd)
586 ICOM_THIS(IShellLinkImpl, iface);
588 FIXME(shell,"(%p)->(showcmd=%x)\n",This, iShowCmd);
591 static HRESULT WINAPI IShellLink_fnGetIconLocation(IShellLink * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
593 ICOM_THIS(IShellLinkImpl, iface);
595 FIXME(shell,"(%p)->(%p len=%u iicon=%p)\n",This, pszIconPath, cchIconPath, piIcon);
596 strncpy(pszIconPath,"shell32.dll",cchIconPath);
600 static HRESULT WINAPI IShellLink_fnSetIconLocation(IShellLink * iface, LPCSTR pszIconPath,INT iIcon)
602 ICOM_THIS(IShellLinkImpl, iface);
604 FIXME(shell,"(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
607 static HRESULT WINAPI IShellLink_fnSetRelativePath(IShellLink * iface, LPCSTR pszPathRel, DWORD dwReserved)
609 ICOM_THIS(IShellLinkImpl, iface);
611 FIXME(shell,"(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved);
614 static HRESULT WINAPI IShellLink_fnResolve(IShellLink * iface, HWND hwnd, DWORD fFlags)
616 ICOM_THIS(IShellLinkImpl, iface);
618 FIXME(shell,"(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
621 static HRESULT WINAPI IShellLink_fnSetPath(IShellLink * iface, LPCSTR pszFile)
623 ICOM_THIS(IShellLinkImpl, iface);
625 FIXME(shell,"(%p)->(path=%s)\n",This, pszFile);
629 /**************************************************************************
630 * IShellLink Implementation
633 static ICOM_VTABLE(IShellLink) slvt =
634 { IShellLink_fnQueryInterface,
636 IShellLink_fnRelease,
637 IShellLink_fnGetPath,
638 IShellLink_fnGetIDList,
639 IShellLink_fnSetIDList,
640 IShellLink_fnGetDescription,
641 IShellLink_fnSetDescription,
642 IShellLink_fnGetWorkingDirectory,
643 IShellLink_fnSetWorkingDirectory,
644 IShellLink_fnGetArguments,
645 IShellLink_fnSetArguments,
646 IShellLink_fnGetHotkey,
647 IShellLink_fnSetHotkey,
648 IShellLink_fnGetShowCmd,
649 IShellLink_fnSetShowCmd,
650 IShellLink_fnGetIconLocation,
651 IShellLink_fnSetIconLocation,
652 IShellLink_fnSetRelativePath,
653 IShellLink_fnResolve,
657 /**************************************************************************
658 * IShellLink's IClassFactory implementation
661 static ICOM_VTABLE(IClassFactory) slwcfvt;
663 /**************************************************************************
664 * IShellLinkW_CF_Constructor
667 LPCLASSFACTORY IShellLinkW_CF_Constructor(void)
669 IClassFactoryImpl* lpclf;
671 lpclf= (IClassFactoryImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl));
673 lpclf->lpvtbl = &slwcfvt;
674 TRACE(shell,"(%p)->()\n",lpclf);
676 return (LPCLASSFACTORY)lpclf;
678 /**************************************************************************
679 * IShellLinkW_CF_QueryInterface
681 static HRESULT WINAPI IShellLinkW_CF_QueryInterface(
682 LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
684 ICOM_THIS(IClassFactoryImpl,iface);
686 WINE_StringFromCLSID((LPCLSID)riid,xriid);
687 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
691 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
692 { *ppvObj = (LPUNKNOWN)This;
694 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
695 { *ppvObj = (LPCLASSFACTORY)This;
699 IUnknown_AddRef((IUnknown*)*ppvObj);
700 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
703 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
704 return E_NOINTERFACE;
706 /******************************************************************************
707 * IShellLinkW_CF_AddRef
709 static ULONG WINAPI IShellLinkW_CF_AddRef(LPCLASSFACTORY iface)
711 ICOM_THIS(IClassFactoryImpl,iface);
712 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
715 return ++(This->ref);
717 /******************************************************************************
718 * IShellLinkW_CF_Release
720 static ULONG WINAPI IShellLinkW_CF_Release(LPCLASSFACTORY iface)
722 ICOM_THIS(IClassFactoryImpl,iface);
723 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
727 { TRACE(shell,"-- destroying IClassFactory(%p)\n",This);
728 HeapFree(GetProcessHeap(),0,This);
733 /******************************************************************************
734 * IShellLinkW_CF_CreateInstance
736 static HRESULT WINAPI IShellLinkW_CF_CreateInstance(
737 LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
739 ICOM_THIS(IClassFactoryImpl,iface);
740 IUnknown *pObj = NULL;
744 WINE_StringFromCLSID((LPCLSID)riid,xriid);
745 TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,xriid,ppObject);
750 { return(CLASS_E_NOAGGREGATION);
753 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLinkW))
754 { pObj = (IUnknown *)IShellLinkW_Constructor();
757 { ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
758 return(E_NOINTERFACE);
762 { return(E_OUTOFMEMORY);
765 hres = pObj->lpvtbl->fnQueryInterface(pObj,riid, ppObject);
766 pObj->lpvtbl->fnRelease(pObj);
767 TRACE(shell,"-- Object created: (%p)->%p\n",This,*ppObject);
771 /******************************************************************************
772 * IShellLinkW_CF_LockServer
775 static HRESULT WINAPI IShellLinkW_CF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
777 ICOM_THIS(IClassFactoryImpl,iface);
778 TRACE(shell,"%p->(0x%x), not implemented\n",This, fLock);
782 static ICOM_VTABLE(IClassFactory) slwcfvt =
784 IShellLinkW_CF_QueryInterface,
785 IShellLinkW_CF_AddRef,
786 IShellLinkW_CF_Release,
787 IShellLinkW_CF_CreateInstance,
788 IShellLinkW_CF_LockServer
792 /**************************************************************************
793 * IShellLink Implementation
798 ICOM_VTABLE(IShellLinkW)* lpvtbl;
800 IPersistFileImpl* lppf;
804 static ICOM_VTABLE(IShellLinkW) slvtw;
806 /**************************************************************************
807 * IShellLinkW_fnConstructor
809 IShellLinkW * IShellLinkW_Constructor(void)
810 { IShellLinkWImpl* sl;
812 sl = (IShellLinkWImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLinkWImpl));
816 sl->lppf = IPersistFile_Constructor();
818 TRACE(shell,"(%p)->()\n",sl);
820 return (IShellLinkW*)sl;
823 /**************************************************************************
824 * IShellLinkW_fnQueryInterface
826 static HRESULT WINAPI IShellLinkW_fnQueryInterface(
827 IShellLinkW * iface, REFIID riid, LPVOID *ppvObj)
829 ICOM_THIS(IShellLinkWImpl, iface);
832 WINE_StringFromCLSID((LPCLSID)riid,xriid);
833 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
837 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
840 else if(IsEqualIID(riid, &IID_IShellLinkW)) /*IShellLinkW*/
841 { *ppvObj = (IShellLinkW *)This;
843 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
844 { *ppvObj = (IPersistFile *)This->lppf;
848 { IShellLink_AddRef((IShellLinkW*)*ppvObj);
849 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
853 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
855 return E_NOINTERFACE;
857 /******************************************************************************
858 * IShellLinkW_fnAddRef
860 static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface)
862 ICOM_THIS(IShellLinkWImpl, iface);
864 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
867 return ++(This->ref);
869 /******************************************************************************
870 * IShellLinkW_fnRelease
873 static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
875 ICOM_THIS(IShellLinkWImpl, iface);
877 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
881 { TRACE(shell,"-- destroying IShellLinkW(%p)\n",This);
882 IPersistFile_Release((IPersistFile*)This->lppf); /* IPersistFile*/
883 HeapFree(GetProcessHeap(),0,This);
889 static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
891 ICOM_THIS(IShellLinkWImpl, iface);
893 FIXME(shell,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
894 lstrcpynAtoW(pszFile,"c:\\foo.bar", cchMaxPath);
898 static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl)
900 ICOM_THIS(IShellLinkWImpl, iface);
902 FIXME(shell,"(%p)->(ppidl=%p)\n",This, ppidl);
903 *ppidl = _ILCreateDesktop();
907 static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl)
909 ICOM_THIS(IShellLinkWImpl, iface);
911 FIXME(shell,"(%p)->(pidl=%p)\n",This, pidl);
915 static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR pszName,INT cchMaxName)
917 ICOM_THIS(IShellLinkWImpl, iface);
919 FIXME(shell,"(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
920 lstrcpynAtoW(pszName,"Description, FIXME",cchMaxName);
924 static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR pszName)
926 ICOM_THIS(IShellLinkWImpl, iface);
928 FIXME(shell,"(%p)->(desc=%s)\n",This, debugstr_w(pszName));
932 static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPWSTR pszDir,INT cchMaxPath)
934 ICOM_THIS(IShellLinkWImpl, iface);
936 FIXME(shell,"(%p)->()\n",This);
937 lstrcpynAtoW(pszDir,"c:\\", cchMaxPath);
941 static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPCWSTR pszDir)
943 ICOM_THIS(IShellLinkWImpl, iface);
945 FIXME(shell,"(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
949 static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR pszArgs,INT cchMaxPath)
951 ICOM_THIS(IShellLinkWImpl, iface);
953 FIXME(shell,"(%p)->(%p len=%u)\n",This, pszArgs, cchMaxPath);
954 lstrcpynAtoW(pszArgs, "", cchMaxPath);
958 static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR pszArgs)
960 ICOM_THIS(IShellLinkWImpl, iface);
962 FIXME(shell,"(%p)->(args=%s)\n",This, debugstr_w(pszArgs));
966 static HRESULT WINAPI IShellLinkW_fnGetHotkey(IShellLinkW * iface, WORD *pwHotkey)
968 ICOM_THIS(IShellLinkWImpl, iface);
970 FIXME(shell,"(%p)->(%p)\n",This, pwHotkey);
975 static HRESULT WINAPI IShellLinkW_fnSetHotkey(IShellLinkW * iface, WORD wHotkey)
977 ICOM_THIS(IShellLinkWImpl, iface);
979 FIXME(shell,"(%p)->(hotkey=%x)\n",This, wHotkey);
983 static HRESULT WINAPI IShellLinkW_fnGetShowCmd(IShellLinkW * iface, INT *piShowCmd)
985 ICOM_THIS(IShellLinkWImpl, iface);
987 FIXME(shell,"(%p)->(%p)\n",This, piShowCmd);
992 static HRESULT WINAPI IShellLinkW_fnSetShowCmd(IShellLinkW * iface, INT iShowCmd)
994 ICOM_THIS(IShellLinkWImpl, iface);
996 FIXME(shell,"(%p)->(showcmd=%x)\n",This, iShowCmd);
1000 static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon)
1002 ICOM_THIS(IShellLinkWImpl, iface);
1004 FIXME(shell,"(%p)->(%p len=%u iicon=%p)\n",This, pszIconPath, cchIconPath, piIcon);
1005 lstrcpynAtoW(pszIconPath,"shell32.dll",cchIconPath);
1010 static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon)
1012 ICOM_THIS(IShellLinkWImpl, iface);
1014 FIXME(shell,"(%p)->(path=%s iicon=%u)\n",This, debugstr_w(pszIconPath), iIcon);
1018 static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR pszPathRel, DWORD dwReserved)
1020 ICOM_THIS(IShellLinkWImpl, iface);
1022 FIXME(shell,"(%p)->(path=%s %lx)\n",This, debugstr_w(pszPathRel), dwReserved);
1026 static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWORD fFlags)
1028 ICOM_THIS(IShellLinkWImpl, iface);
1030 FIXME(shell,"(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
1034 static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile)
1036 ICOM_THIS(IShellLinkWImpl, iface);
1038 FIXME(shell,"(%p)->(path=%s)\n",This, debugstr_w(pszFile));
1042 /**************************************************************************
1043 * IShellLinkW Implementation
1046 static ICOM_VTABLE(IShellLinkW) slvtw =
1047 { IShellLinkW_fnQueryInterface,
1048 IShellLinkW_fnAddRef,
1049 IShellLinkW_fnRelease,
1050 IShellLinkW_fnGetPath,
1051 IShellLinkW_fnGetIDList,
1052 IShellLinkW_fnSetIDList,
1053 IShellLinkW_fnGetDescription,
1054 IShellLinkW_fnSetDescription,
1055 IShellLinkW_fnGetWorkingDirectory,
1056 IShellLinkW_fnSetWorkingDirectory,
1057 IShellLinkW_fnGetArguments,
1058 IShellLinkW_fnSetArguments,
1059 IShellLinkW_fnGetHotkey,
1060 IShellLinkW_fnSetHotkey,
1061 IShellLinkW_fnGetShowCmd,
1062 IShellLinkW_fnSetShowCmd,
1063 IShellLinkW_fnGetIconLocation,
1064 IShellLinkW_fnSetIconLocation,
1065 IShellLinkW_fnSetRelativePath,
1066 IShellLinkW_fnResolve,
1067 IShellLinkW_fnSetPath