Recovery of release 990110 after disk crash.
[wine.git] / dlls / shell32 / shelllink.c
blobddba978660f17ed8970470884e07ae2f5b5cd9af
1 /*
3 * Copyright 1997 Marcus Meissner
4 * Copyright 1998 Juergen Schmied
6 */
8 #include <ctype.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include "ole.h"
12 #include "ole2.h"
13 #include "debug.h"
14 #include "objbase.h"
15 #include "wine/obj_base.h"
16 #include "wine/obj_storage.h"
17 #include "shell.h"
18 #include "winerror.h"
19 #include "winnls.h"
20 #include "winproc.h"
21 #include "commctrl.h"
22 #include "pidl.h"
24 #include "shell32_main.h"
26 /* IPersistFile Implementation */
27 typedef struct _IPersistFile {
28 /* IUnknown fields */
29 ICOM_VTABLE(IPersistFile)* lpvtbl;
30 DWORD ref;
31 } _IPersistFile;
33 static struct ICOM_VTABLE(IPersistFile) pfvt;
36 /**************************************************************************
37 * IPersistFile_Constructor
39 LPPERSISTFILE IPersistFile_Constructor(void)
41 _IPersistFile* sl;
43 sl = (_IPersistFile*)HeapAlloc(GetProcessHeap(),0,sizeof(_IPersistFile));
44 sl->ref = 1;
45 sl->lpvtbl = &pfvt;
47 TRACE(shell,"(%p)->()\n",sl);
48 return (LPPERSISTFILE)sl;
51 /**************************************************************************
52 * IPersistFile_QueryInterface
54 static HRESULT WINAPI IPersistFile_fnQueryInterface(
55 LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj)
57 ICOM_THIS(IPersistFile,iface);
58 char xriid[50];
59 WINE_StringFromCLSID((LPCLSID)riid,xriid);
60 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
62 *ppvObj = NULL;
64 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
65 { *ppvObj = this;
67 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
68 { *ppvObj = (LPPERSISTFILE)this;
71 if(*ppvObj)
72 { IPersistFile_AddRef((IPersistFile*)*ppvObj);
73 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
74 return S_OK;
76 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
77 return E_NOINTERFACE;
79 /******************************************************************************
80 * IPersistFile_AddRef
82 static ULONG WINAPI IPersistFile_fnAddRef(LPUNKNOWN iface)
84 ICOM_THIS(IPersistFile,iface);
85 TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
86 return ++(this->ref);
88 /******************************************************************************
89 * IPersistFile_Release
91 static ULONG WINAPI IPersistFile_fnRelease(LPUNKNOWN iface)
93 ICOM_THIS(IPersistFile,iface);
94 TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
95 if (!--(this->ref))
96 { TRACE(shell,"-- destroying IPersistFile(%p)\n",this);
97 HeapFree(GetProcessHeap(),0,this);
98 return 0;
100 return this->ref;
103 static HRESULT WINAPI IPersistFile_fnGetClassID(const IPersist* iface, CLSID *pClassID)
105 ICOM_CTHIS(IPersistFile,iface);
106 FIXME(shell,"(%p)\n",this);
107 return NOERROR;
109 static HRESULT WINAPI IPersistFile_fnIsDirty(const IPersistFile* iface)
111 ICOM_CTHIS(IPersistFile,iface);
112 FIXME(shell,"(%p)\n",this);
113 return NOERROR;
115 static HRESULT WINAPI IPersistFile_fnLoad(LPPERSISTFILE iface, LPCOLESTR32 pszFileName, DWORD dwMode)
117 ICOM_THIS(IPersistFile,iface);
118 FIXME(shell,"(%p)->(%s)\n",this,debugstr_w(pszFileName));
119 return E_FAIL;
121 static HRESULT WINAPI IPersistFile_fnSave(LPPERSISTFILE iface, LPCOLESTR32 pszFileName, BOOL32 fRemember)
123 ICOM_THIS(IPersistFile,iface);
124 FIXME(shell,"(%p)->(%s)\n",this,debugstr_w(pszFileName));
125 return NOERROR;
127 static HRESULT WINAPI IPersistFile_fnSaveCompleted(LPPERSISTFILE iface, LPCOLESTR32 pszFileName)
129 ICOM_THIS(IPersistFile,iface);
130 FIXME(shell,"(%p)->(%s)\n",this,debugstr_w(pszFileName));
131 return NOERROR;
133 static HRESULT WINAPI IPersistFile_fnGetCurFile(const IPersistFile* iface, LPOLESTR32 *ppszFileName)
135 ICOM_CTHIS(IPersistFile,iface);
136 FIXME(shell,"(%p)\n",this);
137 return NOERROR;
140 static struct ICOM_VTABLE(IPersistFile) pfvt =
144 IPersistFile_fnQueryInterface,
145 IPersistFile_fnAddRef,
146 IPersistFile_fnRelease
148 IPersistFile_fnGetClassID
150 IPersistFile_fnIsDirty,
151 IPersistFile_fnLoad,
152 IPersistFile_fnSave,
153 IPersistFile_fnSaveCompleted,
154 IPersistFile_fnGetCurFile
158 /**************************************************************************
159 * IShellLink's IClassFactory implementation
162 static ICOM_VTABLE(IClassFactory) slcfvt;
164 /**************************************************************************
165 * IShellLink_CF_Constructor
168 LPCLASSFACTORY IShellLink_CF_Constructor(void)
170 _IClassFactory* lpclf;
172 lpclf= (_IClassFactory*)HeapAlloc(GetProcessHeap(),0,sizeof(_IClassFactory));
173 lpclf->ref = 1;
174 lpclf->lpvtbl = &slcfvt;
175 TRACE(shell,"(%p)->()\n",lpclf);
176 return (LPCLASSFACTORY)lpclf;
178 /**************************************************************************
179 * IShellLink_CF_QueryInterface
181 static HRESULT WINAPI IShellLink_CF_QueryInterface(
182 LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj)
184 ICOM_THIS(IClassFactory,iface);
185 char xriid[50];
186 WINE_StringFromCLSID((LPCLSID)riid,xriid);
187 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
189 *ppvObj = NULL;
191 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
192 { *ppvObj = (LPUNKNOWN)this;
194 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
195 { *ppvObj = (LPCLASSFACTORY)this;
198 if(*ppvObj)
199 { IUnknown_AddRef((IUnknown*)*ppvObj);
200 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
201 return S_OK;
203 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
204 return E_NOINTERFACE;
206 /******************************************************************************
207 * IShellLink_CF_AddRef
209 static ULONG WINAPI IShellLink_CF_AddRef(LPUNKNOWN iface)
211 ICOM_THIS(IClassFactory,iface);
212 TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
213 return ++(this->ref);
215 /******************************************************************************
216 * IShellLink_CF_Release
218 static ULONG WINAPI IShellLink_CF_Release(LPUNKNOWN iface)
220 ICOM_THIS(IClassFactory,iface);
221 TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
222 if (!--(this->ref))
223 { TRACE(shell,"-- destroying IClassFactory(%p)\n",this);
224 HeapFree(GetProcessHeap(),0,this);
225 return 0;
227 return this->ref;
229 /******************************************************************************
230 * IShellLink_CF_CreateInstance
232 static HRESULT WINAPI IShellLink_CF_CreateInstance(
233 LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
235 ICOM_THIS(IClassFactory,iface);
236 IUnknown *pObj = NULL;
237 HRESULT hres;
238 char xriid[50];
240 WINE_StringFromCLSID((LPCLSID)riid,xriid);
241 TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",this,pUnknown,xriid,ppObject);
243 *ppObject = NULL;
245 if(pUnknown)
246 { return(CLASS_E_NOAGGREGATION);
249 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLink))
250 { pObj = (IUnknown *)IShellLink_Constructor();
252 else
253 { ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
254 return(E_NOINTERFACE);
257 if (!pObj)
258 { return(E_OUTOFMEMORY);
261 hres = IUnknown_QueryInterface(pObj,riid, ppObject);
262 IUnknown_Release(pObj);
263 TRACE(shell,"-- Object created: (%p)->%p\n",this,*ppObject);
265 return hres;
267 /******************************************************************************
268 * IShellLink_CF_LockServer
270 static HRESULT WINAPI IShellLink_CF_LockServer(LPCLASSFACTORY iface, BOOL32 fLock)
272 ICOM_THIS(IClassFactory,iface);
273 TRACE(shell,"%p->(0x%x), not implemented\n",this, fLock);
274 return E_NOTIMPL;
276 static ICOM_VTABLE(IClassFactory) slcfvt =
279 IShellLink_CF_QueryInterface,
280 IShellLink_CF_AddRef,
281 IShellLink_CF_Release
283 IShellLink_CF_CreateInstance,
284 IShellLink_CF_LockServer
287 /* IShellLink Implementation */
288 static HRESULT WINAPI IShellLink_QueryInterface(LPSHELLLINK,REFIID,LPVOID*);
289 static ULONG WINAPI IShellLink_AddRef(LPSHELLLINK);
290 static ULONG WINAPI IShellLink_Release(LPSHELLLINK);
291 static HRESULT WINAPI IShellLink_GetPath(LPSHELLLINK, LPSTR,INT32, WIN32_FIND_DATA32A *, DWORD);
292 static HRESULT WINAPI IShellLink_GetIDList(LPSHELLLINK, LPITEMIDLIST *);
293 static HRESULT WINAPI IShellLink_SetIDList(LPSHELLLINK, LPCITEMIDLIST);
294 static HRESULT WINAPI IShellLink_GetDescription(LPSHELLLINK, LPSTR,INT32);
295 static HRESULT WINAPI IShellLink_SetDescription(LPSHELLLINK, LPCSTR);
296 static HRESULT WINAPI IShellLink_GetWorkingDirectory(LPSHELLLINK, LPSTR,INT32);
297 static HRESULT WINAPI IShellLink_SetWorkingDirectory(LPSHELLLINK, LPCSTR);
298 static HRESULT WINAPI IShellLink_GetArguments(LPSHELLLINK, LPSTR,INT32);
299 static HRESULT WINAPI IShellLink_SetArguments(LPSHELLLINK, LPCSTR);
300 static HRESULT WINAPI IShellLink_GetHotkey(LPSHELLLINK, WORD *);
301 static HRESULT WINAPI IShellLink_SetHotkey(LPSHELLLINK, WORD);
302 static HRESULT WINAPI IShellLink_GetShowCmd(LPSHELLLINK, INT32 *);
303 static HRESULT WINAPI IShellLink_SetShowCmd(LPSHELLLINK, INT32);
304 static HRESULT WINAPI IShellLink_GetIconLocation(LPSHELLLINK, LPSTR,INT32,INT32 *);
305 static HRESULT WINAPI IShellLink_SetIconLocation(LPSHELLLINK, LPCSTR,INT32);
306 static HRESULT WINAPI IShellLink_SetRelativePath(LPSHELLLINK, LPCSTR, DWORD);
307 static HRESULT WINAPI IShellLink_Resolve(LPSHELLLINK, HWND32, DWORD);
308 static HRESULT WINAPI IShellLink_SetPath(LPSHELLLINK, LPCSTR);
310 /**************************************************************************
311 * IShellLink Implementation
315 static struct IShellLink_VTable slvt =
316 { IShellLink_QueryInterface,
317 IShellLink_AddRef,
318 IShellLink_Release,
319 IShellLink_GetPath,
320 IShellLink_GetIDList,
321 IShellLink_SetIDList,
322 IShellLink_GetDescription,
323 IShellLink_SetDescription,
324 IShellLink_GetWorkingDirectory,
325 IShellLink_SetWorkingDirectory,
326 IShellLink_GetArguments,
327 IShellLink_SetArguments,
328 IShellLink_GetHotkey,
329 IShellLink_SetHotkey,
330 IShellLink_GetShowCmd,
331 IShellLink_SetShowCmd,
332 IShellLink_GetIconLocation,
333 IShellLink_SetIconLocation,
334 IShellLink_SetRelativePath,
335 IShellLink_Resolve,
336 IShellLink_SetPath
339 /**************************************************************************
340 * IShellLink_Constructor
342 LPSHELLLINK IShellLink_Constructor(void)
343 { LPSHELLLINK sl;
345 sl = (LPSHELLLINK)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLink));
346 sl->ref = 1;
347 sl->lpvtbl = &slvt;
349 sl->lppf = IPersistFile_Constructor();
351 TRACE(shell,"(%p)->()\n",sl);
352 return sl;
355 /**************************************************************************
356 * IShellLink::QueryInterface
358 static HRESULT WINAPI IShellLink_QueryInterface(
359 LPSHELLLINK this, REFIID riid, LPVOID *ppvObj)
360 { char xriid[50];
361 WINE_StringFromCLSID((LPCLSID)riid,xriid);
362 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
364 *ppvObj = NULL;
366 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
367 { *ppvObj = this;
369 else if(IsEqualIID(riid, &IID_IShellLink)) /*IShellLink*/
370 { *ppvObj = (LPSHELLLINK)this;
372 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
373 { *ppvObj = (LPPERSISTFILE)this->lppf;
376 if(*ppvObj)
377 { (*(LPSHELLLINK*)ppvObj)->lpvtbl->fnAddRef(this);
378 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
379 return S_OK;
381 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
382 return E_NOINTERFACE;
384 /******************************************************************************
385 * IShellLink_AddRef
387 static ULONG WINAPI IShellLink_AddRef(LPSHELLLINK this)
388 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
389 return ++(this->ref);
391 /******************************************************************************
392 * IShellLink_Release
394 static ULONG WINAPI IShellLink_Release(LPSHELLLINK this)
395 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
396 if (!--(this->ref))
397 { TRACE(shell,"-- destroying IShellLink(%p)\n",this);
398 IPersistFile_Release(this->lppf); /* IPersistFile*/
399 HeapFree(GetProcessHeap(),0,this);
400 return 0;
402 return this->ref;
405 static HRESULT WINAPI IShellLink_GetPath(LPSHELLLINK this, LPSTR pszFile,INT32 cchMaxPath, WIN32_FIND_DATA32A *pfd, DWORD fFlags)
406 { FIXME(shell,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",this, pszFile, cchMaxPath, pfd, fFlags);
407 strncpy(pszFile,"c:\\foo.bar", cchMaxPath);
408 return NOERROR;
410 static HRESULT WINAPI IShellLink_GetIDList(LPSHELLLINK this, LPITEMIDLIST * ppidl)
411 { FIXME(shell,"(%p)->(ppidl=%p)\n",this, ppidl);
412 *ppidl = _ILCreateDesktop();
413 return NOERROR;
415 static HRESULT WINAPI IShellLink_SetIDList(LPSHELLLINK this, LPCITEMIDLIST pidl)
416 { FIXME(shell,"(%p)->(pidl=%p)\n",this, pidl);
417 return NOERROR;
419 static HRESULT WINAPI IShellLink_GetDescription(LPSHELLLINK this, LPSTR pszName,INT32 cchMaxName)
420 { FIXME(shell,"(%p)->(%p len=%u)\n",this, pszName, cchMaxName);
421 strncpy(pszName,"Description, FIXME",cchMaxName);
422 return NOERROR;
424 static HRESULT WINAPI IShellLink_SetDescription(LPSHELLLINK this, LPCSTR pszName)
425 { FIXME(shell,"(%p)->(desc=%s)\n",this, pszName);
426 return NOERROR;
428 static HRESULT WINAPI IShellLink_GetWorkingDirectory(LPSHELLLINK this, LPSTR pszDir,INT32 cchMaxPath)
429 { FIXME(shell,"(%p)->()\n",this);
430 strncpy(pszDir,"c:\\", cchMaxPath);
431 return NOERROR;
433 static HRESULT WINAPI IShellLink_SetWorkingDirectory(LPSHELLLINK this, LPCSTR pszDir)
434 { FIXME(shell,"(%p)->(dir=%s)\n",this, pszDir);
435 return NOERROR;
437 static HRESULT WINAPI IShellLink_GetArguments(LPSHELLLINK this, LPSTR pszArgs,INT32 cchMaxPath)
438 { FIXME(shell,"(%p)->(%p len=%u)\n",this, pszArgs, cchMaxPath);
439 strncpy(pszArgs, "", cchMaxPath);
440 return NOERROR;
442 static HRESULT WINAPI IShellLink_SetArguments(LPSHELLLINK this, LPCSTR pszArgs)
443 { FIXME(shell,"(%p)->(args=%s)\n",this, pszArgs);
444 return NOERROR;
446 static HRESULT WINAPI IShellLink_GetHotkey(LPSHELLLINK this, WORD *pwHotkey)
447 { FIXME(shell,"(%p)->(%p)\n",this, pwHotkey);
448 *pwHotkey=0x0;
449 return NOERROR;
451 static HRESULT WINAPI IShellLink_SetHotkey(LPSHELLLINK this, WORD wHotkey)
452 { FIXME(shell,"(%p)->(hotkey=%x)\n",this, wHotkey);
453 return NOERROR;
455 static HRESULT WINAPI IShellLink_GetShowCmd(LPSHELLLINK this, INT32 *piShowCmd)
456 { FIXME(shell,"(%p)->(%p)\n",this, piShowCmd);
457 *piShowCmd=0;
458 return NOERROR;
460 static HRESULT WINAPI IShellLink_SetShowCmd(LPSHELLLINK this, INT32 iShowCmd)
461 { FIXME(shell,"(%p)->(showcmd=%x)\n",this, iShowCmd);
462 return NOERROR;
464 static HRESULT WINAPI IShellLink_GetIconLocation(LPSHELLLINK this, LPSTR pszIconPath,INT32 cchIconPath,INT32 *piIcon)
465 { FIXME(shell,"(%p)->(%p len=%u iicon=%p)\n",this, pszIconPath, cchIconPath, piIcon);
466 strncpy(pszIconPath,"shell32.dll",cchIconPath);
467 *piIcon=1;
468 return NOERROR;
470 static HRESULT WINAPI IShellLink_SetIconLocation(LPSHELLLINK this, LPCSTR pszIconPath,INT32 iIcon)
471 { FIXME(shell,"(%p)->(path=%s iicon=%u)\n",this, pszIconPath, iIcon);
472 return NOERROR;
474 static HRESULT WINAPI IShellLink_SetRelativePath(LPSHELLLINK this, LPCSTR pszPathRel, DWORD dwReserved)
475 { FIXME(shell,"(%p)->(path=%s %lx)\n",this, pszPathRel, dwReserved);
476 return NOERROR;
478 static HRESULT WINAPI IShellLink_Resolve(LPSHELLLINK this, HWND32 hwnd, DWORD fFlags)
479 { FIXME(shell,"(%p)->(hwnd=%x flags=%lx)\n",this, hwnd, fFlags);
480 return NOERROR;
482 static HRESULT WINAPI IShellLink_SetPath(LPSHELLLINK this, LPCSTR pszFile)
483 { FIXME(shell,"(%p)->(path=%s)\n",this, pszFile);
484 return NOERROR;
487 /**************************************************************************
488 * IShellLink's IClassFactory implementation
491 static ICOM_VTABLE(IClassFactory) slwcfvt;
493 /**************************************************************************
494 * IShellLinkW_CF_Constructor
497 LPCLASSFACTORY IShellLinkW_CF_Constructor(void)
499 _IClassFactory* lpclf;
501 lpclf= (_IClassFactory*)HeapAlloc(GetProcessHeap(),0,sizeof(_IClassFactory));
502 lpclf->ref = 1;
503 lpclf->lpvtbl = &slwcfvt;
504 TRACE(shell,"(%p)->()\n",lpclf);
505 return (LPCLASSFACTORY)lpclf;
507 /**************************************************************************
508 * IShellLinkW_CF_QueryInterface
510 static HRESULT WINAPI IShellLinkW_CF_QueryInterface(
511 LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj)
513 ICOM_THIS(IClassFactory,iface);
514 char xriid[50];
515 WINE_StringFromCLSID((LPCLSID)riid,xriid);
516 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
518 *ppvObj = NULL;
520 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
521 { *ppvObj = (LPUNKNOWN)this;
523 else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
524 { *ppvObj = (LPCLASSFACTORY)this;
527 if(*ppvObj) {
528 IUnknown_AddRef((IUnknown*)*ppvObj);
529 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
530 return S_OK;
532 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
533 return E_NOINTERFACE;
535 /******************************************************************************
536 * IShellLinkW_CF_AddRef
538 static ULONG WINAPI IShellLinkW_CF_AddRef(LPUNKNOWN iface)
540 ICOM_THIS(IClassFactory,iface);
541 TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
542 return ++(this->ref);
544 /******************************************************************************
545 * IShellLinkW_CF_Release
547 static ULONG WINAPI IShellLinkW_CF_Release(LPUNKNOWN iface)
549 ICOM_THIS(IClassFactory,iface);
550 TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
551 if (!--(this->ref))
552 { TRACE(shell,"-- destroying IClassFactory(%p)\n",this);
553 HeapFree(GetProcessHeap(),0,this);
554 return 0;
556 return this->ref;
558 /******************************************************************************
559 * IShellLinkW_CF_CreateInstance
561 static HRESULT WINAPI IShellLinkW_CF_CreateInstance(
562 LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
564 ICOM_THIS(IClassFactory,iface);
565 IUnknown *pObj = NULL;
566 HRESULT hres;
567 char xriid[50];
569 WINE_StringFromCLSID((LPCLSID)riid,xriid);
570 TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",this,pUnknown,xriid,ppObject);
572 *ppObject = NULL;
574 if(pUnknown)
575 { return(CLASS_E_NOAGGREGATION);
578 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLinkW))
579 { pObj = (IUnknown *)IShellLinkW_Constructor();
581 else
582 { ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
583 return(E_NOINTERFACE);
586 if (!pObj)
587 { return(E_OUTOFMEMORY);
590 hres = pObj->lpvtbl->fnQueryInterface(pObj,riid, ppObject);
591 pObj->lpvtbl->fnRelease(pObj);
592 TRACE(shell,"-- Object created: (%p)->%p\n",this,*ppObject);
594 return hres;
596 /******************************************************************************
597 * IShellLinkW_CF_LockServer
600 static HRESULT WINAPI IShellLinkW_CF_LockServer(LPCLASSFACTORY iface, BOOL32 fLock)
602 ICOM_THIS(IClassFactory,iface);
603 TRACE(shell,"%p->(0x%x), not implemented\n",this, fLock);
604 return E_NOTIMPL;
607 static ICOM_VTABLE(IClassFactory) slwcfvt =
610 IShellLinkW_CF_QueryInterface,
611 IShellLinkW_CF_AddRef,
612 IShellLinkW_CF_Release
614 IShellLinkW_CF_CreateInstance,
615 IShellLinkW_CF_LockServer
618 /* IShellLinkW Implementation */
619 static HRESULT WINAPI IShellLinkW_QueryInterface(LPSHELLLINKW,REFIID,LPVOID*);
620 static ULONG WINAPI IShellLinkW_AddRef(LPSHELLLINKW);
621 static ULONG WINAPI IShellLinkW_Release(LPSHELLLINKW);
622 static HRESULT WINAPI IShellLinkW_GetPath(LPSHELLLINKW, LPWSTR,INT32, WIN32_FIND_DATA32A *, DWORD);
623 static HRESULT WINAPI IShellLinkW_GetIDList(LPSHELLLINKW, LPITEMIDLIST *);
624 static HRESULT WINAPI IShellLinkW_SetIDList(LPSHELLLINKW, LPCITEMIDLIST);
625 static HRESULT WINAPI IShellLinkW_GetDescription(LPSHELLLINKW, LPWSTR,INT32);
626 static HRESULT WINAPI IShellLinkW_SetDescription(LPSHELLLINKW, LPCWSTR);
627 static HRESULT WINAPI IShellLinkW_GetWorkingDirectory(LPSHELLLINKW, LPWSTR,INT32);
628 static HRESULT WINAPI IShellLinkW_SetWorkingDirectory(LPSHELLLINKW, LPCWSTR);
629 static HRESULT WINAPI IShellLinkW_GetArguments(LPSHELLLINKW, LPWSTR,INT32);
630 static HRESULT WINAPI IShellLinkW_SetArguments(LPSHELLLINKW, LPCWSTR);
631 static HRESULT WINAPI IShellLinkW_GetHotkey(LPSHELLLINKW, WORD *);
632 static HRESULT WINAPI IShellLinkW_SetHotkey(LPSHELLLINKW, WORD);
633 static HRESULT WINAPI IShellLinkW_GetShowCmd(LPSHELLLINKW, INT32 *);
634 static HRESULT WINAPI IShellLinkW_SetShowCmd(LPSHELLLINKW, INT32);
635 static HRESULT WINAPI IShellLinkW_GetIconLocation(LPSHELLLINKW, LPWSTR,INT32,INT32 *);
636 static HRESULT WINAPI IShellLinkW_SetIconLocation(LPSHELLLINKW, LPCWSTR,INT32);
637 static HRESULT WINAPI IShellLinkW_SetRelativePath(LPSHELLLINKW, LPCWSTR, DWORD);
638 static HRESULT WINAPI IShellLinkW_Resolve(LPSHELLLINKW, HWND32, DWORD);
639 static HRESULT WINAPI IShellLinkW_SetPath(LPSHELLLINKW, LPCWSTR);
641 /**************************************************************************
642 * IShellLinkW Implementation
645 static struct IShellLinkW_VTable slvtw =
646 { IShellLinkW_QueryInterface,
647 IShellLinkW_AddRef,
648 IShellLinkW_Release,
649 IShellLinkW_GetPath,
650 IShellLinkW_GetIDList,
651 IShellLinkW_SetIDList,
652 IShellLinkW_GetDescription,
653 IShellLinkW_SetDescription,
654 IShellLinkW_GetWorkingDirectory,
655 IShellLinkW_SetWorkingDirectory,
656 IShellLinkW_GetArguments,
657 IShellLinkW_SetArguments,
658 IShellLinkW_GetHotkey,
659 IShellLinkW_SetHotkey,
660 IShellLinkW_GetShowCmd,
661 IShellLinkW_SetShowCmd,
662 IShellLinkW_GetIconLocation,
663 IShellLinkW_SetIconLocation,
664 IShellLinkW_SetRelativePath,
665 IShellLinkW_Resolve,
666 IShellLinkW_SetPath
669 /**************************************************************************
670 * IShellLinkW_Constructor
672 LPSHELLLINKW IShellLinkW_Constructor(void)
673 { LPSHELLLINKW sl;
675 sl = (LPSHELLLINKW)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLinkW));
676 sl->ref = 1;
677 sl->lpvtbl = &slvtw;
679 sl->lppf = IPersistFile_Constructor();
681 TRACE(shell,"(%p)->()\n",sl);
682 return sl;
685 /**************************************************************************
686 * IShellLinkW::QueryInterface
688 static HRESULT WINAPI IShellLinkW_QueryInterface(
689 LPSHELLLINKW this, REFIID riid, LPVOID *ppvObj)
690 { char xriid[50];
691 WINE_StringFromCLSID((LPCLSID)riid,xriid);
692 TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",this,xriid);
694 *ppvObj = NULL;
696 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
697 { *ppvObj = this;
699 else if(IsEqualIID(riid, &IID_IShellLinkW)) /*IShellLinkW*/
700 { *ppvObj = (LPSHELLLINKW)this;
702 else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
703 { *ppvObj = (LPPERSISTFILE)this->lppf;
706 if(*ppvObj)
707 { (*(LPSHELLLINKW*)ppvObj)->lpvtbl->fnAddRef(this);
708 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
709 return S_OK;
711 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
712 return E_NOINTERFACE;
714 /******************************************************************************
715 * IShellLinkW_AddRef
717 static ULONG WINAPI IShellLinkW_AddRef(LPSHELLLINKW this)
718 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
719 return ++(this->ref);
721 /******************************************************************************
722 * IClassFactory_Release
724 static ULONG WINAPI IShellLinkW_Release(LPSHELLLINKW this)
725 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
726 if (!--(this->ref))
727 { TRACE(shell,"-- destroying IShellLinkW(%p)\n",this);
728 IPersistFile_Release(this->lppf); /* IPersistFile*/
729 HeapFree(GetProcessHeap(),0,this);
730 return 0;
732 return this->ref;
735 static HRESULT WINAPI IShellLinkW_GetPath(LPSHELLLINKW this, LPWSTR pszFile,INT32 cchMaxPath, WIN32_FIND_DATA32A *pfd, DWORD fFlags)
736 { FIXME(shell,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",this, pszFile, cchMaxPath, pfd, fFlags);
737 lstrcpynAtoW(pszFile,"c:\\foo.bar", cchMaxPath);
738 return NOERROR;
740 static HRESULT WINAPI IShellLinkW_GetIDList(LPSHELLLINKW this, LPITEMIDLIST * ppidl)
741 { FIXME(shell,"(%p)->(ppidl=%p)\n",this, ppidl);
742 *ppidl = _ILCreateDesktop();
743 return NOERROR;
745 static HRESULT WINAPI IShellLinkW_SetIDList(LPSHELLLINKW this, LPCITEMIDLIST pidl)
746 { FIXME(shell,"(%p)->(pidl=%p)\n",this, pidl);
747 return NOERROR;
749 static HRESULT WINAPI IShellLinkW_GetDescription(LPSHELLLINKW this, LPWSTR pszName,INT32 cchMaxName)
750 { FIXME(shell,"(%p)->(%p len=%u)\n",this, pszName, cchMaxName);
751 lstrcpynAtoW(pszName,"Description, FIXME",cchMaxName);
752 return NOERROR;
754 static HRESULT WINAPI IShellLinkW_SetDescription(LPSHELLLINKW this, LPCWSTR pszName)
755 { FIXME(shell,"(%p)->(desc=%s)\n",this, debugstr_w(pszName));
756 return NOERROR;
758 static HRESULT WINAPI IShellLinkW_GetWorkingDirectory(LPSHELLLINKW this, LPWSTR pszDir,INT32 cchMaxPath)
759 { FIXME(shell,"(%p)->()\n",this);
760 lstrcpynAtoW(pszDir,"c:\\", cchMaxPath);
761 return NOERROR;
763 static HRESULT WINAPI IShellLinkW_SetWorkingDirectory(LPSHELLLINKW this, LPCWSTR pszDir)
764 { FIXME(shell,"(%p)->(dir=%s)\n",this, debugstr_w(pszDir));
765 return NOERROR;
767 static HRESULT WINAPI IShellLinkW_GetArguments(LPSHELLLINKW this, LPWSTR pszArgs,INT32 cchMaxPath)
768 { FIXME(shell,"(%p)->(%p len=%u)\n",this, pszArgs, cchMaxPath);
769 lstrcpynAtoW(pszArgs, "", cchMaxPath);
770 return NOERROR;
772 static HRESULT WINAPI IShellLinkW_SetArguments(LPSHELLLINKW this, LPCWSTR pszArgs)
773 { FIXME(shell,"(%p)->(args=%s)\n",this, debugstr_w(pszArgs));
774 return NOERROR;
776 static HRESULT WINAPI IShellLinkW_GetHotkey(LPSHELLLINKW this, WORD *pwHotkey)
777 { FIXME(shell,"(%p)->(%p)\n",this, pwHotkey);
778 *pwHotkey=0x0;
779 return NOERROR;
781 static HRESULT WINAPI IShellLinkW_SetHotkey(LPSHELLLINKW this, WORD wHotkey)
782 { FIXME(shell,"(%p)->(hotkey=%x)\n",this, wHotkey);
783 return NOERROR;
785 static HRESULT WINAPI IShellLinkW_GetShowCmd(LPSHELLLINKW this, INT32 *piShowCmd)
786 { FIXME(shell,"(%p)->(%p)\n",this, piShowCmd);
787 *piShowCmd=0;
788 return NOERROR;
790 static HRESULT WINAPI IShellLinkW_SetShowCmd(LPSHELLLINKW this, INT32 iShowCmd)
791 { FIXME(shell,"(%p)->(showcmd=%x)\n",this, iShowCmd);
792 return NOERROR;
794 static HRESULT WINAPI IShellLinkW_GetIconLocation(LPSHELLLINKW this, LPWSTR pszIconPath,INT32 cchIconPath,INT32 *piIcon)
795 { FIXME(shell,"(%p)->(%p len=%u iicon=%p)\n",this, pszIconPath, cchIconPath, piIcon);
796 lstrcpynAtoW(pszIconPath,"shell32.dll",cchIconPath);
797 *piIcon=1;
798 return NOERROR;
800 static HRESULT WINAPI IShellLinkW_SetIconLocation(LPSHELLLINKW this, LPCWSTR pszIconPath,INT32 iIcon)
801 { FIXME(shell,"(%p)->(path=%s iicon=%u)\n",this, debugstr_w(pszIconPath), iIcon);
802 return NOERROR;
804 static HRESULT WINAPI IShellLinkW_SetRelativePath(LPSHELLLINKW this, LPCWSTR pszPathRel, DWORD dwReserved)
805 { FIXME(shell,"(%p)->(path=%s %lx)\n",this, debugstr_w(pszPathRel), dwReserved);
806 return NOERROR;
808 static HRESULT WINAPI IShellLinkW_Resolve(LPSHELLLINKW this, HWND32 hwnd, DWORD fFlags)
809 { FIXME(shell,"(%p)->(hwnd=%x flags=%lx)\n",this, hwnd, fFlags);
810 return NOERROR;
812 static HRESULT WINAPI IShellLinkW_SetPath(LPSHELLLINKW this, LPCWSTR pszFile)
813 { FIXME(shell,"(%p)->(path=%s)\n",this, debugstr_w(pszFile));
814 return NOERROR;