New debug scheme with explicit debug channels declaration.
[wine.git] / dlls / shell32 / shelllink.c
blob6b8af51f3743c3e9b77ff98a0195329574f274b8
1 /*
3 * Copyright 1997 Marcus Meissner
4 * Copyright 1998 Juergen Schmied
6 */
8 #include <string.h>
9 #include "debug.h"
10 #include "winerror.h"
12 #include "wine/obj_base.h"
13 #include "wine/obj_storage.h"
14 #include "wine/obj_shelllink.h"
16 #include "heap.h"
17 #include "winnls.h"
18 #include "pidl.h"
19 #include "shell32_main.h"
20 #include "shlguid.h"
22 DEFAULT_DEBUG_CHANNEL(shell)
24 /* link file formats */
26 #pragma (1);
28 /* lnk elements: simple link has 0x0B */
29 #define WORKDIR 0x10
30 #define ARGUMENT 0x20
31 #define ICON 0x40
32 /* startup type */
33 #define NORMAL 0x01
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;
55 #pragma (4);
57 /* IPersistFile Implementation */
58 typedef struct
60 /* IUnknown fields */
61 ICOM_VTABLE(IPersistFile)* lpvtbl;
62 DWORD ref;
63 LPSTR sPath;
64 LPITEMIDLIST pPidl;
66 } IPersistFileImpl;
68 static struct ICOM_VTABLE(IPersistFile) pfvt;
71 /**************************************************************************
72 * IPersistFile_Constructor
74 IPersistFileImpl * IPersistFile_Constructor(void)
76 IPersistFileImpl* sl;
78 sl = (IPersistFileImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IPersistFileImpl));
79 sl->ref = 1;
80 sl->lpvtbl = &pfvt;
81 sl->sPath = NULL;
82 sl->pPidl = NULL;
84 TRACE(shell,"(%p)->()\n",sl);
85 shell32_ObjCount++;
86 return sl;
89 /**************************************************************************
90 * IPersistFile_QueryInterface
92 static HRESULT WINAPI IPersistFile_fnQueryInterface(
93 IPersistFile* iface, REFIID riid, LPVOID *ppvObj)
95 ICOM_THIS(IPersistFileImpl,iface);
97 char xriid[50];
98 WINE_StringFromCLSID((LPCLSID)riid,xriid);
99 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
101 *ppvObj = NULL;
103 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
104 { *ppvObj = This;
106 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
107 { *ppvObj = (LPPERSISTFILE)This;
110 if(*ppvObj)
111 { IPersistFile_AddRef((IPersistFile*)*ppvObj);
112 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
113 return S_OK;
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);
127 shell32_ObjCount++;
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);
139 shell32_ObjCount--;
141 if (!--(This->ref))
142 { TRACE(shell,"-- destroying IPersistFile(%p)\n",This);
143 if (This->sPath)
144 HeapFree(GetProcessHeap(),0,This->sPath);
145 if (This->pPidl)
146 SHFree(This->pPidl);
147 HeapFree(GetProcessHeap(),0,This);
148 return 0;
150 return This->ref;
153 static HRESULT WINAPI IPersistFile_fnGetClassID(const IPersistFile* iface, CLSID *pClassID)
155 ICOM_CTHIS(IPersistFile,iface);
156 FIXME(shell,"(%p)\n",This);
157 return NOERROR;
159 static HRESULT WINAPI IPersistFile_fnIsDirty(const IPersistFile* iface)
161 ICOM_CTHIS(IPersistFile,iface);
162 FIXME(shell,"(%p)\n",This);
163 return NOERROR;
165 static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
167 ICOM_THIS(IPersistFileImpl,iface);
169 OFSTRUCT ofs;
170 LPSTR sFile = HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName);
171 HFILE hFile = OpenFile( sFile, &ofs, OF_READ );
172 HANDLE hMapping;
173 PLINK_HEADER pImage;
174 HRESULT hRet = E_FAIL;
175 CHAR sTemp[512];
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");
183 goto end_1;
186 if ( !(pImage = (PLINK_HEADER) MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0)))
187 { WARN(shell,"failed to mmap filemap.\n");
188 goto end_2;
191 if (!( (pImage->MagicStr == 0x0000004CL) && IsEqualIID(&pImage->MagicGuid, &CLSID_ShellLink)))
192 { TRACE(shell,"file isn't a lnk\n");
193 goto end_3;
196 { /* for debugging */
197 SYSTEMTIME time;
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);
217 hRet = NOERROR;
218 end_3: UnmapViewOfFile(pImage);
219 end_2: CloseHandle(hMapping);
220 end_1: _lclose( hFile);
222 return hRet;
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));
229 return NOERROR;
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));
235 return NOERROR;
237 static HRESULT WINAPI IPersistFile_fnGetCurFile(const IPersistFile* iface, LPOLESTR *ppszFileName)
239 ICOM_CTHIS(IPersistFileImpl,iface);
240 FIXME(shell,"(%p)\n",This);
241 return NOERROR;
244 static struct ICOM_VTABLE(IPersistFile) pfvt =
246 IPersistFile_fnQueryInterface,
247 IPersistFile_fnAddRef,
248 IPersistFile_fnRelease,
249 IPersistFile_fnGetClassID,
250 IPersistFile_fnIsDirty,
251 IPersistFile_fnLoad,
252 IPersistFile_fnSave,
253 IPersistFile_fnSaveCompleted,
254 IPersistFile_fnGetCurFile
258 /**************************************************************************
259 * IShellLink's IClassFactory implementation
261 typedef struct
263 /* IUnknown fields */
264 ICOM_VTABLE(IClassFactory)* lpvtbl;
265 DWORD ref;
266 } IClassFactoryImpl;
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));
279 lpclf->ref = 1;
280 lpclf->lpvtbl = &slcfvt;
281 TRACE(shell,"(%p)->()\n",lpclf);
282 shell32_ObjCount++;
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);
292 char xriid[50];
293 WINE_StringFromCLSID((LPCLSID)riid,xriid);
294 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
296 *ppvObj = NULL;
298 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
299 { *ppvObj = (LPUNKNOWN)This;
301 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
302 { *ppvObj = (LPCLASSFACTORY)This;
305 if(*ppvObj)
306 { IUnknown_AddRef((IUnknown*)*ppvObj);
307 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
308 return S_OK;
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);
321 shell32_ObjCount++;
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);
332 shell32_ObjCount--;
333 if (!--(This->ref))
334 { TRACE(shell,"-- destroying IClassFactory(%p)\n",This);
335 HeapFree(GetProcessHeap(),0,This);
336 return 0;
338 return This->ref;
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;
348 HRESULT hres;
349 char xriid[50];
351 WINE_StringFromCLSID((LPCLSID)riid,xriid);
352 TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,xriid,ppObject);
354 *ppObject = NULL;
356 if(pUnknown)
357 { return(CLASS_E_NOAGGREGATION);
360 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLink))
361 { pObj = (IUnknown *)IShellLink_Constructor();
363 else
364 { ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
365 return(E_NOINTERFACE);
368 if (!pObj)
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);
376 return hres;
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);
385 return E_NOTIMPL;
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
400 typedef struct
402 ICOM_VTABLE(IShellLink)* lpvtbl;
403 DWORD ref;
404 IPersistFileImpl* lppf;
406 } IShellLinkImpl;
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));
417 sl->ref = 1;
418 sl->lpvtbl = &slvt;
420 sl->lppf = IPersistFile_Constructor();
422 TRACE(shell,"(%p)->()\n",sl);
423 shell32_ObjCount++;
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);
434 char xriid[50];
435 WINE_StringFromCLSID((LPCLSID)riid,xriid);
436 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
438 *ppvObj = NULL;
440 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
441 { *ppvObj = This;
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;
450 if(*ppvObj)
451 { IShellLink_AddRef((IShellLink*)*ppvObj);
452 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
453 return S_OK;
455 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
456 return E_NOINTERFACE;
458 /******************************************************************************
459 * IShellLink_AddRef
461 static ULONG WINAPI IShellLink_fnAddRef(IShellLink * iface)
463 ICOM_THIS(IShellLinkImpl, iface);
465 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
467 shell32_ObjCount++;
468 return ++(This->ref);
470 /******************************************************************************
471 * IShellLink_Release
473 static ULONG WINAPI IShellLink_fnRelease(IShellLink * iface)
475 ICOM_THIS(IShellLinkImpl, iface);
477 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
479 shell32_ObjCount--;
480 if (!--(This->ref))
481 { TRACE(shell,"-- destroying IShellLink(%p)\n",This);
482 IPersistFile_Release((IPersistFile*) This->lppf); /* IPersistFile*/
483 HeapFree(GetProcessHeap(),0,This);
484 return 0;
486 return This->ref;
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);
496 return NOERROR;
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);
505 return NOERROR;
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);
516 return NOERROR;
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);
524 return NOERROR;
526 static HRESULT WINAPI IShellLink_fnSetDescription(IShellLink * iface, LPCSTR pszName)
528 ICOM_THIS(IShellLinkImpl, iface);
530 FIXME(shell,"(%p)->(desc=%s)\n",This, pszName);
531 return NOERROR;
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);
539 return NOERROR;
541 static HRESULT WINAPI IShellLink_fnSetWorkingDirectory(IShellLink * iface, LPCSTR pszDir)
543 ICOM_THIS(IShellLinkImpl, iface);
545 FIXME(shell,"(%p)->(dir=%s)\n",This, pszDir);
546 return NOERROR;
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);
554 return NOERROR;
556 static HRESULT WINAPI IShellLink_fnSetArguments(IShellLink * iface, LPCSTR pszArgs)
558 ICOM_THIS(IShellLinkImpl, iface);
560 FIXME(shell,"(%p)->(args=%s)\n",This, pszArgs);
561 return NOERROR;
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);
568 *pwHotkey=0x0;
569 return NOERROR;
571 static HRESULT WINAPI IShellLink_fnSetHotkey(IShellLink * iface, WORD wHotkey)
573 ICOM_THIS(IShellLinkImpl, iface);
575 FIXME(shell,"(%p)->(hotkey=%x)\n",This, wHotkey);
576 return NOERROR;
578 static HRESULT WINAPI IShellLink_fnGetShowCmd(IShellLink * iface, INT *piShowCmd)
580 ICOM_THIS(IShellLinkImpl, iface);
582 FIXME(shell,"(%p)->(%p)\n",This, piShowCmd);
583 *piShowCmd=0;
584 return NOERROR;
586 static HRESULT WINAPI IShellLink_fnSetShowCmd(IShellLink * iface, INT iShowCmd)
588 ICOM_THIS(IShellLinkImpl, iface);
590 FIXME(shell,"(%p)->(showcmd=%x)\n",This, iShowCmd);
591 return NOERROR;
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);
599 *piIcon=1;
600 return NOERROR;
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);
607 return NOERROR;
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);
614 return NOERROR;
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);
621 return NOERROR;
623 static HRESULT WINAPI IShellLink_fnSetPath(IShellLink * iface, LPCSTR pszFile)
625 ICOM_THIS(IShellLinkImpl, iface);
627 FIXME(shell,"(%p)->(path=%s)\n",This, pszFile);
628 return NOERROR;
631 /**************************************************************************
632 * IShellLink Implementation
635 static ICOM_VTABLE(IShellLink) slvt =
636 { IShellLink_fnQueryInterface,
637 IShellLink_fnAddRef,
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,
656 IShellLink_fnSetPath
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));
674 lpclf->ref = 1;
675 lpclf->lpvtbl = &slwcfvt;
676 TRACE(shell,"(%p)->()\n",lpclf);
677 shell32_ObjCount++;
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);
687 char xriid[50];
688 WINE_StringFromCLSID((LPCLSID)riid,xriid);
689 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
691 *ppvObj = NULL;
693 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
694 { *ppvObj = (LPUNKNOWN)This;
696 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
697 { *ppvObj = (LPCLASSFACTORY)This;
700 if(*ppvObj) {
701 IUnknown_AddRef((IUnknown*)*ppvObj);
702 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
703 return S_OK;
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);
716 shell32_ObjCount++;
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);
727 shell32_ObjCount--;
728 if (!--(This->ref))
729 { TRACE(shell,"-- destroying IClassFactory(%p)\n",This);
730 HeapFree(GetProcessHeap(),0,This);
731 return 0;
733 return This->ref;
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;
743 HRESULT hres;
744 char xriid[50];
746 WINE_StringFromCLSID((LPCLSID)riid,xriid);
747 TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,xriid,ppObject);
749 *ppObject = NULL;
751 if(pUnknown)
752 { return(CLASS_E_NOAGGREGATION);
755 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLinkW))
756 { pObj = (IUnknown *)IShellLinkW_Constructor();
758 else
759 { ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
760 return(E_NOINTERFACE);
763 if (!pObj)
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);
771 return hres;
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);
781 return E_NOTIMPL;
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
798 typedef struct
800 ICOM_VTABLE(IShellLinkW)* lpvtbl;
801 DWORD ref;
802 IPersistFileImpl* lppf;
804 } IShellLinkWImpl;
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));
815 sl->ref = 1;
816 sl->lpvtbl = &slvtw;
818 sl->lppf = IPersistFile_Constructor();
820 TRACE(shell,"(%p)->()\n",sl);
821 shell32_ObjCount++;
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);
833 char xriid[50];
834 WINE_StringFromCLSID((LPCLSID)riid,xriid);
835 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
837 *ppvObj = NULL;
839 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
840 { *ppvObj = This;
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;
849 if(*ppvObj)
850 { IShellLink_AddRef((IShellLinkW*)*ppvObj);
851 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
852 return S_OK;
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);
868 shell32_ObjCount++;
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);
881 shell32_ObjCount--;
882 if (!--(This->ref))
883 { TRACE(shell,"-- destroying IShellLinkW(%p)\n",This);
884 IPersistFile_Release((IPersistFile*)This->lppf); /* IPersistFile*/
885 HeapFree(GetProcessHeap(),0,This);
886 return 0;
888 return This->ref;
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);
897 return NOERROR;
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();
906 return NOERROR;
909 static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl)
911 ICOM_THIS(IShellLinkWImpl, iface);
913 FIXME(shell,"(%p)->(pidl=%p)\n",This, pidl);
914 return NOERROR;
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);
923 return NOERROR;
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));
931 return NOERROR;
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);
940 return NOERROR;
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));
948 return NOERROR;
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);
957 return NOERROR;
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));
965 return NOERROR;
968 static HRESULT WINAPI IShellLinkW_fnGetHotkey(IShellLinkW * iface, WORD *pwHotkey)
970 ICOM_THIS(IShellLinkWImpl, iface);
972 FIXME(shell,"(%p)->(%p)\n",This, pwHotkey);
973 *pwHotkey=0x0;
974 return NOERROR;
977 static HRESULT WINAPI IShellLinkW_fnSetHotkey(IShellLinkW * iface, WORD wHotkey)
979 ICOM_THIS(IShellLinkWImpl, iface);
981 FIXME(shell,"(%p)->(hotkey=%x)\n",This, wHotkey);
982 return NOERROR;
985 static HRESULT WINAPI IShellLinkW_fnGetShowCmd(IShellLinkW * iface, INT *piShowCmd)
987 ICOM_THIS(IShellLinkWImpl, iface);
989 FIXME(shell,"(%p)->(%p)\n",This, piShowCmd);
990 *piShowCmd=0;
991 return NOERROR;
994 static HRESULT WINAPI IShellLinkW_fnSetShowCmd(IShellLinkW * iface, INT iShowCmd)
996 ICOM_THIS(IShellLinkWImpl, iface);
998 FIXME(shell,"(%p)->(showcmd=%x)\n",This, iShowCmd);
999 return NOERROR;
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);
1008 *piIcon=1;
1009 return NOERROR;
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);
1017 return NOERROR;
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);
1025 return NOERROR;
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);
1033 return NOERROR;
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));
1041 return NOERROR;
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