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 This->pPidl = ILClone (&pImage->Pidl);
214 _ILGetPidlPath(&pImage->Pidl, sTemp, 512);
215 This->sPath = HEAP_strdupA ( GetProcessHeap(), 0, sTemp);
218 end_3: UnmapViewOfFile(pImage);
219 end_2: CloseHandle(hMapping);
220 end_1: _lclose( hFile);
225 static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
227 ICOM_THIS(IPersistFileImpl,iface);
228 FIXME(shell,"(%p)->(%s)\n",This,debugstr_w(pszFileName));
231 static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
233 ICOM_THIS(IPersistFileImpl,iface);
234 FIXME(shell,"(%p)->(%s)\n",This,debugstr_w(pszFileName));
237 static HRESULT WINAPI IPersistFile_fnGetCurFile(const IPersistFile* iface, LPOLESTR *ppszFileName)
239 ICOM_CTHIS(IPersistFileImpl,iface);
240 FIXME(shell,"(%p)\n",This);
244 static struct ICOM_VTABLE(IPersistFile) pfvt =
246 IPersistFile_fnQueryInterface,
247 IPersistFile_fnAddRef,
248 IPersistFile_fnRelease,
249 IPersistFile_fnGetClassID,
250 IPersistFile_fnIsDirty,
253 IPersistFile_fnSaveCompleted,
254 IPersistFile_fnGetCurFile
258 /**************************************************************************
259 * IShellLink's IClassFactory implementation
263 /* IUnknown fields */
264 ICOM_VTABLE(IClassFactory)* lpvtbl;
268 static ICOM_VTABLE(IClassFactory) slcfvt;
270 /**************************************************************************
271 * IShellLink_CF_Constructor
274 LPCLASSFACTORY IShellLink_CF_Constructor(void)
276 IClassFactoryImpl* lpclf;
278 lpclf= (IClassFactoryImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl));
280 lpclf->lpvtbl = &slcfvt;
281 TRACE(shell,"(%p)->()\n",lpclf);
283 return (LPCLASSFACTORY)lpclf;
285 /**************************************************************************
286 * IShellLink_CF_QueryInterface
288 static HRESULT WINAPI IShellLink_CF_QueryInterface(
289 IClassFactory* iface, REFIID riid, LPVOID *ppvObj)
291 ICOM_THIS(IClassFactoryImpl,iface);
293 WINE_StringFromCLSID((LPCLSID)riid,xriid);
294 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
298 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
299 { *ppvObj = (LPUNKNOWN)This;
301 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
302 { *ppvObj = (LPCLASSFACTORY)This;
306 { IUnknown_AddRef((IUnknown*)*ppvObj);
307 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
310 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
311 return E_NOINTERFACE;
313 /******************************************************************************
314 * IShellLink_CF_AddRef
316 static ULONG WINAPI IShellLink_CF_AddRef(IClassFactory* iface)
318 ICOM_THIS(IClassFactoryImpl,iface);
319 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
322 return ++(This->ref);
324 /******************************************************************************
325 * IShellLink_CF_Release
327 static ULONG WINAPI IShellLink_CF_Release(IClassFactory* iface)
329 ICOM_THIS(IClassFactoryImpl,iface);
330 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
334 { TRACE(shell,"-- destroying IClassFactory(%p)\n",This);
335 HeapFree(GetProcessHeap(),0,This);
340 /******************************************************************************
341 * IShellLink_CF_CreateInstance
343 static HRESULT WINAPI IShellLink_CF_CreateInstance(
344 IClassFactory* iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
346 ICOM_THIS(IClassFactoryImpl,iface);
347 IUnknown *pObj = NULL;
351 WINE_StringFromCLSID((LPCLSID)riid,xriid);
352 TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,xriid,ppObject);
357 { return(CLASS_E_NOAGGREGATION);
360 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLink))
361 { pObj = (IUnknown *)IShellLink_Constructor();
364 { ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
365 return(E_NOINTERFACE);
369 { return(E_OUTOFMEMORY);
372 hres = IUnknown_QueryInterface(pObj,riid, ppObject);
373 IUnknown_Release(pObj);
374 TRACE(shell,"-- Object created: (%p)->%p\n",This,*ppObject);
378 /******************************************************************************
379 * IShellLink_CF_LockServer
381 static HRESULT WINAPI IShellLink_CF_LockServer(IClassFactory* iface, BOOL fLock)
383 ICOM_THIS(IClassFactoryImpl,iface);
384 TRACE(shell,"%p->(0x%x), not implemented\n",This, fLock);
387 static ICOM_VTABLE(IClassFactory) slcfvt =
389 IShellLink_CF_QueryInterface,
390 IShellLink_CF_AddRef,
391 IShellLink_CF_Release,
392 IShellLink_CF_CreateInstance,
393 IShellLink_CF_LockServer
396 /**************************************************************************
397 * IShellLink Implementation
402 ICOM_VTABLE(IShellLink)* lpvtbl;
404 IPersistFileImpl* lppf;
408 static ICOM_VTABLE(IShellLink) slvt;
410 /**************************************************************************
411 * IShellLink_Constructor
413 IShellLink * IShellLink_Constructor(void)
414 { IShellLinkImpl * sl;
416 sl = (IShellLinkImpl *)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLinkImpl));
420 sl->lppf = IPersistFile_Constructor();
422 TRACE(shell,"(%p)->()\n",sl);
424 return (IShellLink *)sl;
427 /**************************************************************************
428 * IShellLink::QueryInterface
430 static HRESULT WINAPI IShellLink_fnQueryInterface( IShellLink * iface, REFIID riid, LPVOID *ppvObj)
432 ICOM_THIS(IShellLinkImpl, iface);
435 WINE_StringFromCLSID((LPCLSID)riid,xriid);
436 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
440 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
443 else if(IsEqualIID(riid, &IID_IShellLink)) /*IShellLink*/
444 { *ppvObj = (IShellLink *)This;
446 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
447 { *ppvObj = (IPersistFile *)This->lppf;
451 { IShellLink_AddRef((IShellLink*)*ppvObj);
452 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
455 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
456 return E_NOINTERFACE;
458 /******************************************************************************
461 static ULONG WINAPI IShellLink_fnAddRef(IShellLink * iface)
463 ICOM_THIS(IShellLinkImpl, iface);
465 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
468 return ++(This->ref);
470 /******************************************************************************
473 static ULONG WINAPI IShellLink_fnRelease(IShellLink * iface)
475 ICOM_THIS(IShellLinkImpl, iface);
477 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
481 { TRACE(shell,"-- destroying IShellLink(%p)\n",This);
482 IPersistFile_Release((IPersistFile*) This->lppf); /* IPersistFile*/
483 HeapFree(GetProcessHeap(),0,This);
489 static HRESULT WINAPI IShellLink_fnGetPath(IShellLink * iface, LPSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
491 ICOM_THIS(IShellLinkImpl, iface);
493 TRACE(shell,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
495 strncpy(pszFile,This->lppf->sPath, cchMaxPath);
498 static HRESULT WINAPI IShellLink_fnGetIDList(IShellLink * iface, LPITEMIDLIST * ppidl)
500 ICOM_THIS(IShellLinkImpl, iface);
502 TRACE(shell,"(%p)->(ppidl=%p)\n",This, ppidl);
504 *ppidl = ILClone(This->lppf->pPidl);
507 static HRESULT WINAPI IShellLink_fnSetIDList(IShellLink * iface, LPCITEMIDLIST pidl)
509 ICOM_THIS(IShellLinkImpl, iface);
511 TRACE (shell,"(%p)->(pidl=%p)\n",This, pidl);
513 if (This->lppf->pPidl)
514 SHFree(This->lppf->pPidl);
515 This->lppf->pPidl = ILClone (pidl);
518 static HRESULT WINAPI IShellLink_fnGetDescription(IShellLink * iface, LPSTR pszName,INT cchMaxName)
520 ICOM_THIS(IShellLinkImpl, iface);
522 FIXME(shell,"(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
523 strncpy(pszName,"Description, FIXME",cchMaxName);
526 static HRESULT WINAPI IShellLink_fnSetDescription(IShellLink * iface, LPCSTR pszName)
528 ICOM_THIS(IShellLinkImpl, iface);
530 FIXME(shell,"(%p)->(desc=%s)\n",This, pszName);
533 static HRESULT WINAPI IShellLink_fnGetWorkingDirectory(IShellLink * iface, LPSTR pszDir,INT cchMaxPath)
535 ICOM_THIS(IShellLinkImpl, iface);
537 FIXME(shell,"(%p)->()\n",This);
538 strncpy(pszDir,"c:\\", cchMaxPath);
541 static HRESULT WINAPI IShellLink_fnSetWorkingDirectory(IShellLink * iface, LPCSTR pszDir)
543 ICOM_THIS(IShellLinkImpl, iface);
545 FIXME(shell,"(%p)->(dir=%s)\n",This, pszDir);
548 static HRESULT WINAPI IShellLink_fnGetArguments(IShellLink * iface, LPSTR pszArgs,INT cchMaxPath)
550 ICOM_THIS(IShellLinkImpl, iface);
552 FIXME(shell,"(%p)->(%p len=%u)\n",This, pszArgs, cchMaxPath);
553 strncpy(pszArgs, "", cchMaxPath);
556 static HRESULT WINAPI IShellLink_fnSetArguments(IShellLink * iface, LPCSTR pszArgs)
558 ICOM_THIS(IShellLinkImpl, iface);
560 FIXME(shell,"(%p)->(args=%s)\n",This, pszArgs);
563 static HRESULT WINAPI IShellLink_fnGetHotkey(IShellLink * iface, WORD *pwHotkey)
565 ICOM_THIS(IShellLinkImpl, iface);
567 FIXME(shell,"(%p)->(%p) returning 0\n",This, pwHotkey);
571 static HRESULT WINAPI IShellLink_fnSetHotkey(IShellLink * iface, WORD wHotkey)
573 ICOM_THIS(IShellLinkImpl, iface);
575 FIXME(shell,"(%p)->(hotkey=%x)\n",This, wHotkey);
578 static HRESULT WINAPI IShellLink_fnGetShowCmd(IShellLink * iface, INT *piShowCmd)
580 ICOM_THIS(IShellLinkImpl, iface);
582 FIXME(shell,"(%p)->(%p)\n",This, piShowCmd);
586 static HRESULT WINAPI IShellLink_fnSetShowCmd(IShellLink * iface, INT iShowCmd)
588 ICOM_THIS(IShellLinkImpl, iface);
590 FIXME(shell,"(%p)->(showcmd=%x)\n",This, iShowCmd);
593 static HRESULT WINAPI IShellLink_fnGetIconLocation(IShellLink * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
595 ICOM_THIS(IShellLinkImpl, iface);
597 FIXME(shell,"(%p)->(%p len=%u iicon=%p)\n",This, pszIconPath, cchIconPath, piIcon);
598 strncpy(pszIconPath,"shell32.dll",cchIconPath);
602 static HRESULT WINAPI IShellLink_fnSetIconLocation(IShellLink * iface, LPCSTR pszIconPath,INT iIcon)
604 ICOM_THIS(IShellLinkImpl, iface);
606 FIXME(shell,"(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
609 static HRESULT WINAPI IShellLink_fnSetRelativePath(IShellLink * iface, LPCSTR pszPathRel, DWORD dwReserved)
611 ICOM_THIS(IShellLinkImpl, iface);
613 FIXME(shell,"(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved);
616 static HRESULT WINAPI IShellLink_fnResolve(IShellLink * iface, HWND hwnd, DWORD fFlags)
618 ICOM_THIS(IShellLinkImpl, iface);
620 FIXME(shell,"(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
623 static HRESULT WINAPI IShellLink_fnSetPath(IShellLink * iface, LPCSTR pszFile)
625 ICOM_THIS(IShellLinkImpl, iface);
627 FIXME(shell,"(%p)->(path=%s)\n",This, pszFile);
631 /**************************************************************************
632 * IShellLink Implementation
635 static ICOM_VTABLE(IShellLink) slvt =
636 { IShellLink_fnQueryInterface,
638 IShellLink_fnRelease,
639 IShellLink_fnGetPath,
640 IShellLink_fnGetIDList,
641 IShellLink_fnSetIDList,
642 IShellLink_fnGetDescription,
643 IShellLink_fnSetDescription,
644 IShellLink_fnGetWorkingDirectory,
645 IShellLink_fnSetWorkingDirectory,
646 IShellLink_fnGetArguments,
647 IShellLink_fnSetArguments,
648 IShellLink_fnGetHotkey,
649 IShellLink_fnSetHotkey,
650 IShellLink_fnGetShowCmd,
651 IShellLink_fnSetShowCmd,
652 IShellLink_fnGetIconLocation,
653 IShellLink_fnSetIconLocation,
654 IShellLink_fnSetRelativePath,
655 IShellLink_fnResolve,
659 /**************************************************************************
660 * IShellLink's IClassFactory implementation
663 static ICOM_VTABLE(IClassFactory) slwcfvt;
665 /**************************************************************************
666 * IShellLinkW_CF_Constructor
669 LPCLASSFACTORY IShellLinkW_CF_Constructor(void)
671 IClassFactoryImpl* lpclf;
673 lpclf= (IClassFactoryImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl));
675 lpclf->lpvtbl = &slwcfvt;
676 TRACE(shell,"(%p)->()\n",lpclf);
678 return (LPCLASSFACTORY)lpclf;
680 /**************************************************************************
681 * IShellLinkW_CF_QueryInterface
683 static HRESULT WINAPI IShellLinkW_CF_QueryInterface(
684 LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
686 ICOM_THIS(IClassFactoryImpl,iface);
688 WINE_StringFromCLSID((LPCLSID)riid,xriid);
689 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
693 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
694 { *ppvObj = (LPUNKNOWN)This;
696 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
697 { *ppvObj = (LPCLASSFACTORY)This;
701 IUnknown_AddRef((IUnknown*)*ppvObj);
702 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
705 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
706 return E_NOINTERFACE;
708 /******************************************************************************
709 * IShellLinkW_CF_AddRef
711 static ULONG WINAPI IShellLinkW_CF_AddRef(LPCLASSFACTORY iface)
713 ICOM_THIS(IClassFactoryImpl,iface);
714 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
717 return ++(This->ref);
719 /******************************************************************************
720 * IShellLinkW_CF_Release
722 static ULONG WINAPI IShellLinkW_CF_Release(LPCLASSFACTORY iface)
724 ICOM_THIS(IClassFactoryImpl,iface);
725 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
729 { TRACE(shell,"-- destroying IClassFactory(%p)\n",This);
730 HeapFree(GetProcessHeap(),0,This);
735 /******************************************************************************
736 * IShellLinkW_CF_CreateInstance
738 static HRESULT WINAPI IShellLinkW_CF_CreateInstance(
739 LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
741 ICOM_THIS(IClassFactoryImpl,iface);
742 IUnknown *pObj = NULL;
746 WINE_StringFromCLSID((LPCLSID)riid,xriid);
747 TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,xriid,ppObject);
752 { return(CLASS_E_NOAGGREGATION);
755 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLinkW))
756 { pObj = (IUnknown *)IShellLinkW_Constructor();
759 { ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
760 return(E_NOINTERFACE);
764 { return(E_OUTOFMEMORY);
767 hres = pObj->lpvtbl->fnQueryInterface(pObj,riid, ppObject);
768 pObj->lpvtbl->fnRelease(pObj);
769 TRACE(shell,"-- Object created: (%p)->%p\n",This,*ppObject);
773 /******************************************************************************
774 * IShellLinkW_CF_LockServer
777 static HRESULT WINAPI IShellLinkW_CF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
779 ICOM_THIS(IClassFactoryImpl,iface);
780 TRACE(shell,"%p->(0x%x), not implemented\n",This, fLock);
784 static ICOM_VTABLE(IClassFactory) slwcfvt =
786 IShellLinkW_CF_QueryInterface,
787 IShellLinkW_CF_AddRef,
788 IShellLinkW_CF_Release,
789 IShellLinkW_CF_CreateInstance,
790 IShellLinkW_CF_LockServer
794 /**************************************************************************
795 * IShellLink Implementation
800 ICOM_VTABLE(IShellLinkW)* lpvtbl;
802 IPersistFileImpl* lppf;
806 static ICOM_VTABLE(IShellLinkW) slvtw;
808 /**************************************************************************
809 * IShellLinkW_fnConstructor
811 IShellLinkW * IShellLinkW_Constructor(void)
812 { IShellLinkWImpl* sl;
814 sl = (IShellLinkWImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLinkWImpl));
818 sl->lppf = IPersistFile_Constructor();
820 TRACE(shell,"(%p)->()\n",sl);
822 return (IShellLinkW*)sl;
825 /**************************************************************************
826 * IShellLinkW_fnQueryInterface
828 static HRESULT WINAPI IShellLinkW_fnQueryInterface(
829 IShellLinkW * iface, REFIID riid, LPVOID *ppvObj)
831 ICOM_THIS(IShellLinkWImpl, iface);
834 WINE_StringFromCLSID((LPCLSID)riid,xriid);
835 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
839 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
842 else if(IsEqualIID(riid, &IID_IShellLinkW)) /*IShellLinkW*/
843 { *ppvObj = (IShellLinkW *)This;
845 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
846 { *ppvObj = (IPersistFile *)This->lppf;
850 { IShellLink_AddRef((IShellLinkW*)*ppvObj);
851 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
855 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
857 return E_NOINTERFACE;
859 /******************************************************************************
860 * IShellLinkW_fnAddRef
862 static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface)
864 ICOM_THIS(IShellLinkWImpl, iface);
866 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
869 return ++(This->ref);
871 /******************************************************************************
872 * IShellLinkW_fnRelease
875 static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
877 ICOM_THIS(IShellLinkWImpl, iface);
879 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
883 { TRACE(shell,"-- destroying IShellLinkW(%p)\n",This);
884 IPersistFile_Release((IPersistFile*)This->lppf); /* IPersistFile*/
885 HeapFree(GetProcessHeap(),0,This);
891 static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
893 ICOM_THIS(IShellLinkWImpl, iface);
895 FIXME(shell,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
896 lstrcpynAtoW(pszFile,"c:\\foo.bar", cchMaxPath);
900 static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl)
902 ICOM_THIS(IShellLinkWImpl, iface);
904 FIXME(shell,"(%p)->(ppidl=%p)\n",This, ppidl);
905 *ppidl = _ILCreateDesktop();
909 static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl)
911 ICOM_THIS(IShellLinkWImpl, iface);
913 FIXME(shell,"(%p)->(pidl=%p)\n",This, pidl);
917 static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR pszName,INT cchMaxName)
919 ICOM_THIS(IShellLinkWImpl, iface);
921 FIXME(shell,"(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
922 lstrcpynAtoW(pszName,"Description, FIXME",cchMaxName);
926 static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR pszName)
928 ICOM_THIS(IShellLinkWImpl, iface);
930 FIXME(shell,"(%p)->(desc=%s)\n",This, debugstr_w(pszName));
934 static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPWSTR pszDir,INT cchMaxPath)
936 ICOM_THIS(IShellLinkWImpl, iface);
938 FIXME(shell,"(%p)->()\n",This);
939 lstrcpynAtoW(pszDir,"c:\\", cchMaxPath);
943 static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPCWSTR pszDir)
945 ICOM_THIS(IShellLinkWImpl, iface);
947 FIXME(shell,"(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
951 static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR pszArgs,INT cchMaxPath)
953 ICOM_THIS(IShellLinkWImpl, iface);
955 FIXME(shell,"(%p)->(%p len=%u)\n",This, pszArgs, cchMaxPath);
956 lstrcpynAtoW(pszArgs, "", cchMaxPath);
960 static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR pszArgs)
962 ICOM_THIS(IShellLinkWImpl, iface);
964 FIXME(shell,"(%p)->(args=%s)\n",This, debugstr_w(pszArgs));
968 static HRESULT WINAPI IShellLinkW_fnGetHotkey(IShellLinkW * iface, WORD *pwHotkey)
970 ICOM_THIS(IShellLinkWImpl, iface);
972 FIXME(shell,"(%p)->(%p)\n",This, pwHotkey);
977 static HRESULT WINAPI IShellLinkW_fnSetHotkey(IShellLinkW * iface, WORD wHotkey)
979 ICOM_THIS(IShellLinkWImpl, iface);
981 FIXME(shell,"(%p)->(hotkey=%x)\n",This, wHotkey);
985 static HRESULT WINAPI IShellLinkW_fnGetShowCmd(IShellLinkW * iface, INT *piShowCmd)
987 ICOM_THIS(IShellLinkWImpl, iface);
989 FIXME(shell,"(%p)->(%p)\n",This, piShowCmd);
994 static HRESULT WINAPI IShellLinkW_fnSetShowCmd(IShellLinkW * iface, INT iShowCmd)
996 ICOM_THIS(IShellLinkWImpl, iface);
998 FIXME(shell,"(%p)->(showcmd=%x)\n",This, iShowCmd);
1002 static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon)
1004 ICOM_THIS(IShellLinkWImpl, iface);
1006 FIXME(shell,"(%p)->(%p len=%u iicon=%p)\n",This, pszIconPath, cchIconPath, piIcon);
1007 lstrcpynAtoW(pszIconPath,"shell32.dll",cchIconPath);
1012 static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon)
1014 ICOM_THIS(IShellLinkWImpl, iface);
1016 FIXME(shell,"(%p)->(path=%s iicon=%u)\n",This, debugstr_w(pszIconPath), iIcon);
1020 static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR pszPathRel, DWORD dwReserved)
1022 ICOM_THIS(IShellLinkWImpl, iface);
1024 FIXME(shell,"(%p)->(path=%s %lx)\n",This, debugstr_w(pszPathRel), dwReserved);
1028 static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWORD fFlags)
1030 ICOM_THIS(IShellLinkWImpl, iface);
1032 FIXME(shell,"(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
1036 static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile)
1038 ICOM_THIS(IShellLinkWImpl, iface);
1040 FIXME(shell,"(%p)->(path=%s)\n",This, debugstr_w(pszFile));
1044 /**************************************************************************
1045 * IShellLinkW Implementation
1048 static ICOM_VTABLE(IShellLinkW) slvtw =
1049 { IShellLinkW_fnQueryInterface,
1050 IShellLinkW_fnAddRef,
1051 IShellLinkW_fnRelease,
1052 IShellLinkW_fnGetPath,
1053 IShellLinkW_fnGetIDList,
1054 IShellLinkW_fnSetIDList,
1055 IShellLinkW_fnGetDescription,
1056 IShellLinkW_fnSetDescription,
1057 IShellLinkW_fnGetWorkingDirectory,
1058 IShellLinkW_fnSetWorkingDirectory,
1059 IShellLinkW_fnGetArguments,
1060 IShellLinkW_fnSetArguments,
1061 IShellLinkW_fnGetHotkey,
1062 IShellLinkW_fnSetHotkey,
1063 IShellLinkW_fnGetShowCmd,
1064 IShellLinkW_fnSetShowCmd,
1065 IShellLinkW_fnGetIconLocation,
1066 IShellLinkW_fnSetIconLocation,
1067 IShellLinkW_fnSetRelativePath,
1068 IShellLinkW_fnResolve,
1069 IShellLinkW_fnSetPath