Release 0.9.14.
[wine/multimedia.git] / dlls / ole32 / filemoniker.c
blobe251833b76e22d7e58273a22b7cc096b3988fb7e
1 /*
2 * FileMonikers implementation
4 * Copyright 1999 Noomen Hamza
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <assert.h>
22 #include <stdarg.h>
23 #include <string.h>
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winerror.h"
32 #include "winnls.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
35 #include "objbase.h"
36 #include "moniker.h"
38 #include "compobj_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(ole);
42 const CLSID CLSID_FileMoniker = {
43 0x303, 0, 0, {0xC0, 0, 0, 0, 0, 0, 0, 0x46}
46 /* filemoniker data structure */
47 typedef struct FileMonikerImpl{
49 const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
51 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
52 * two monikers are equal. That's whay IROTData interface is implemented by monikers.
54 const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
56 LONG ref; /* reference counter for this object */
58 LPOLESTR filePathName; /* path string identified by this filemoniker */
60 IUnknown *pMarshal; /* custom marshaler */
61 } FileMonikerImpl;
63 static inline IMoniker *impl_from_IROTData( IROTData *iface )
65 return (IMoniker *)((char*)iface - FIELD_OFFSET(FileMonikerImpl, lpvtbl2));
68 /* Local function used by filemoniker implementation */
69 static HRESULT WINAPI FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName);
70 static HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* iface);
72 /*******************************************************************************
73 * FileMoniker_QueryInterface
75 static HRESULT WINAPI
76 FileMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
78 FileMonikerImpl *This = (FileMonikerImpl *)iface;
80 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
82 /* Perform a sanity check on the parameters.*/
83 if ( (This==0) || (ppvObject==0) )
84 return E_INVALIDARG;
86 /* Initialize the return parameter */
87 *ppvObject = 0;
89 /* Compare the riid with the interface IDs implemented by this object.*/
90 if (IsEqualIID(&IID_IUnknown, riid) ||
91 IsEqualIID(&IID_IPersist, riid) ||
92 IsEqualIID(&IID_IPersistStream,riid) ||
93 IsEqualIID(&IID_IMoniker, riid)
95 *ppvObject = iface;
97 else if (IsEqualIID(&IID_IROTData, riid))
98 *ppvObject = (IROTData*)&(This->lpvtbl2);
99 else if (IsEqualIID(&IID_IMarshal, riid))
101 HRESULT hr = S_OK;
102 if (!This->pMarshal)
103 hr = MonikerMarshal_Create(iface, &This->pMarshal);
104 if (hr != S_OK)
105 return hr;
106 return IUnknown_QueryInterface(This->pMarshal, riid, ppvObject);
109 /* Check that we obtained an interface.*/
110 if ((*ppvObject)==0)
111 return E_NOINTERFACE;
113 /* Query Interface always increases the reference count by one when it is successful */
114 IMoniker_AddRef(iface);
116 return S_OK;
119 /******************************************************************************
120 * FileMoniker_AddRef
122 static ULONG WINAPI
123 FileMonikerImpl_AddRef(IMoniker* iface)
125 FileMonikerImpl *This = (FileMonikerImpl *)iface;
127 TRACE("(%p)\n",iface);
129 return InterlockedIncrement(&This->ref);
132 /******************************************************************************
133 * FileMoniker_Release
135 static ULONG WINAPI
136 FileMonikerImpl_Release(IMoniker* iface)
138 FileMonikerImpl *This = (FileMonikerImpl *)iface;
139 ULONG ref;
141 TRACE("(%p)\n",iface);
143 ref = InterlockedDecrement(&This->ref);
145 /* destroy the object if there's no more reference on it */
146 if (ref == 0) FileMonikerImpl_Destroy(This);
148 return ref;
151 /******************************************************************************
152 * FileMoniker_GetClassID
154 static HRESULT WINAPI
155 FileMonikerImpl_GetClassID(IMoniker* iface, CLSID *pClassID)
157 TRACE("(%p,%p)\n",iface,pClassID);
159 if (pClassID==NULL)
160 return E_POINTER;
162 *pClassID = CLSID_FileMoniker;
164 return S_OK;
167 /******************************************************************************
168 * FileMoniker_IsDirty
170 * Note that the OLE-provided implementations of the IPersistStream::IsDirty
171 * method in the OLE-provided moniker interfaces always return S_FALSE because
172 * their internal state never changes.
174 static HRESULT WINAPI
175 FileMonikerImpl_IsDirty(IMoniker* iface)
178 TRACE("(%p)\n",iface);
180 return S_FALSE;
183 /******************************************************************************
184 * FileMoniker_Load
186 * this function locates and reads from the stream the filePath string
187 * written by FileMonikerImpl_Save
189 static HRESULT WINAPI
190 FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
192 HRESULT res;
193 CHAR* filePathA = NULL;
194 WCHAR* filePathW = NULL;
195 ULONG bread;
196 WORD wbuffer;
197 DWORD dwbuffer, bytesA, bytesW, len;
198 int i;
200 FileMonikerImpl *This = (FileMonikerImpl *)iface;
202 TRACE("(%p,%p)\n",iface,pStm);
204 /* first WORD must be 0 */
205 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
206 if (bread!=sizeof(WORD) || wbuffer!=0)
208 WARN("Couldn't read 0 word\n");
209 goto fail;
212 /* read filePath string length (plus one) */
213 res=IStream_Read(pStm,&bytesA,sizeof(DWORD),&bread);
214 if (bread != sizeof(DWORD))
216 WARN("Couldn't read file string length\n");
217 goto fail;
220 /* read filePath string */
221 filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
222 if (!filePathA)
224 res = E_OUTOFMEMORY;
225 goto fail;
228 res=IStream_Read(pStm,filePathA,bytesA,&bread);
229 if (bread != bytesA)
231 WARN("Couldn't read file path string\n");
232 goto fail;
235 /* read the first constant */
236 IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
237 if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF)
239 WARN("Couldn't read 0xDEADFFFF constant\n");
240 goto fail;
243 for(i=0;i<5;i++)
245 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
246 if (bread!=sizeof(DWORD) || dwbuffer!=0)
248 WARN("Couldn't read 0 padding\n");
249 goto fail;
253 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
254 if (bread!=sizeof(DWORD))
255 goto fail;
257 if (!dwbuffer) /* No W-string */
259 bytesA--;
260 len=MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, bytesA, NULL, 0);
261 if (!len)
262 goto fail;
264 filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
265 if (!filePathW)
267 res = E_OUTOFMEMORY;
268 goto fail;
270 MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, -1, filePathW, len+1);
271 goto succeed;
274 if (dwbuffer < 6)
275 goto fail;
277 bytesW=dwbuffer - 6;
279 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
280 if (bread!=sizeof(DWORD) || dwbuffer!=bytesW)
281 goto fail;
283 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
284 if (bread!=sizeof(WORD) || wbuffer!=0x3)
285 goto fail;
287 len=bytesW/sizeof(WCHAR);
288 filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
289 if(!filePathW)
291 res = E_OUTOFMEMORY;
292 goto fail;
294 res=IStream_Read(pStm,filePathW,bytesW,&bread);
295 if (bread!=bytesW)
296 goto fail;
298 filePathW[len]=0;
300 succeed:
301 HeapFree(GetProcessHeap(),0,filePathA);
302 HeapFree(GetProcessHeap(),0,This->filePathName);
303 This->filePathName=filePathW;
305 return S_OK;
307 fail:
308 HeapFree(GetProcessHeap(), 0, filePathA);
309 HeapFree(GetProcessHeap(), 0, filePathW);
311 if (SUCCEEDED(res))
312 res = E_FAIL;
313 return res;
316 /******************************************************************************
317 * FileMoniker_Save
319 * This function saves data of this object. In the beginning I thought
320 * that I have just to write the filePath string on Stream. But, when I
321 * tested this function with windows programs samples, I noticed that it
322 * was not the case. This implementation is based on XP SP2. Other versions
323 * of Windows have minor variations.
325 * Data which must be written on stream is:
326 * 1) WORD constant:zero
327 * 2) length of the path string ("\0" included)
328 * 3) path string type A
329 * 4) DWORD constant : 0xDEADFFFF
330 * 5) five DWORD constant: zero
331 * 6) If we're only writing the multibyte version,
332 * write a zero DWORD and finish.
334 * 7) DWORD: double-length of the the path string type W ("\0" not
335 * included)
336 * 8) WORD constant: 0x3
337 * 9) filePath unicode string.
340 static HRESULT WINAPI
341 FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
343 FileMonikerImpl *This = (FileMonikerImpl *)iface;
345 HRESULT res;
346 LPOLESTR filePathW=This->filePathName;
347 CHAR* filePathA;
348 DWORD bytesA, bytesW, len;
350 static const DWORD DEADFFFF = 0xDEADFFFF; /* Constants */
351 static const DWORD ZERO = 0;
352 static const WORD THREE = 0x3;
354 int i;
355 BOOL bUsedDefault, bWriteWide;
357 TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
359 if (pStm==NULL)
360 return E_POINTER;
362 /* write a 0 WORD */
363 res=IStream_Write(pStm,&ZERO,sizeof(WORD),NULL);
364 if (!SUCCEEDED(res)) return res;
366 /* write length of filePath string ( 0 included )*/
367 bytesA = WideCharToMultiByte( CP_ACP, 0, filePathW, -1, NULL, 0, NULL, NULL );
368 res=IStream_Write(pStm,&bytesA,sizeof(DWORD),NULL);
369 if (!SUCCEEDED(res)) return res;
371 /* write A string (with '\0') */
372 filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
373 if (!filePathA)
374 return E_OUTOFMEMORY;
375 WideCharToMultiByte( CP_ACP, 0, filePathW, -1, filePathA, bytesA, NULL, &bUsedDefault);
376 res=IStream_Write(pStm,filePathA,bytesA,NULL);
377 HeapFree(GetProcessHeap(),0,filePathA);
378 if (!SUCCEEDED(res)) return res;
380 /* write a DWORD 0xDEADFFFF */
381 res=IStream_Write(pStm,&DEADFFFF,sizeof(DWORD),NULL);
382 if (!SUCCEEDED(res)) return res;
384 /* write 5 zero DWORDs */
385 for(i=0;i<5;i++)
387 res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
388 if (!SUCCEEDED(res)) return res;
391 /* Write the wide version if:
392 * + couldn't convert to CP_ACP,
393 * or + it's a directory,
394 * or + there's a character > 0xFF
396 len = lstrlenW(filePathW);
397 bWriteWide = (bUsedDefault || (len > 0 && filePathW[len-1]=='\\' ));
398 if (!bWriteWide)
400 WCHAR* pch;
401 for(pch=filePathW;*pch;++pch)
403 if (*pch > 0xFF)
405 bWriteWide = TRUE;
406 break;
411 if (!bWriteWide)
413 res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
414 return res;
417 /* write bytes needed for the filepathW (without 0) + 6 */
418 bytesW = len*sizeof(WCHAR) + 6;
419 res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
420 if (!SUCCEEDED(res)) return res;
422 /* try again, without the extra 6 */
423 bytesW -= 6;
424 res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
425 if (!SUCCEEDED(res)) return res;
427 /* write a WORD 3 */
428 res=IStream_Write(pStm,&THREE,sizeof(WORD),NULL);
429 if (!SUCCEEDED(res)) return res;
431 /* write W string (no 0) */
432 res=IStream_Write(pStm,filePathW,bytesW,NULL);
434 return res;
437 /******************************************************************************
438 * FileMoniker_GetSizeMax
440 static HRESULT WINAPI
441 FileMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
443 FileMonikerImpl *This = (FileMonikerImpl *)iface;
445 TRACE("(%p,%p)\n",iface,pcbSize);
447 if (!pcbSize)
448 return E_POINTER;
450 /* We could calculate exactly (see ...::Save()) but instead
451 * we'll make a quick over-estimate, like Windows (NT4, XP) does.
453 pcbSize->u.LowPart = 0x38 + 4 * lstrlenW(This->filePathName);
454 pcbSize->u.HighPart = 0;
456 return S_OK;
459 /******************************************************************************
460 * FileMoniker_Destroy (local function)
461 *******************************************************************************/
462 HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* This)
464 TRACE("(%p)\n",This);
466 if (This->pMarshal) IUnknown_Release(This->pMarshal);
467 HeapFree(GetProcessHeap(),0,This->filePathName);
468 HeapFree(GetProcessHeap(),0,This);
470 return S_OK;
473 /******************************************************************************
474 * FileMoniker_BindToObject
476 static HRESULT WINAPI
477 FileMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
478 REFIID riid, VOID** ppvResult)
480 HRESULT res=E_FAIL;
481 CLSID clsID;
482 IUnknown* pObj=0;
483 IRunningObjectTable *prot=0;
484 IPersistFile *ppf=0;
485 IClassFactory *pcf=0;
486 IClassActivator *pca=0;
488 FileMonikerImpl *This = (FileMonikerImpl *)iface;
490 *ppvResult=0;
492 TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
494 if(pmkToLeft==NULL){
496 res=IBindCtx_GetRunningObjectTable(pbc,&prot);
498 if (SUCCEEDED(res)){
499 /* if the requested class was loaded before ! we don't need to reload it */
500 res = IRunningObjectTable_GetObject(prot,iface,&pObj);
502 if (res==S_FALSE){
503 /* first activation of this class */
504 res=GetClassFile(This->filePathName,&clsID);
505 if (SUCCEEDED(res)){
507 res=CoCreateInstance(&clsID,NULL,CLSCTX_ALL,&IID_IPersistFile,(void**)&ppf);
508 if (SUCCEEDED(res)){
510 res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
511 if (SUCCEEDED(res)){
513 pObj=(IUnknown*)ppf;
514 IUnknown_AddRef(pObj);
521 else{
522 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassFactory,(void**)&pcf);
524 if (res==E_NOINTERFACE){
526 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca);
528 if (res==E_NOINTERFACE)
529 return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED;
531 if (pcf!=NULL){
533 IClassFactory_CreateInstance(pcf,NULL,&IID_IPersistFile,(void**)&ppf);
535 res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
537 if (SUCCEEDED(res)){
539 pObj=(IUnknown*)ppf;
540 IUnknown_AddRef(pObj);
543 if (pca!=NULL){
545 FIXME("()\n");
547 /*res=GetClassFile(This->filePathName,&clsID);
549 if (SUCCEEDED(res)){
551 res=IClassActivator_GetClassObject(pca,&clsID,CLSCTX_ALL,0,&IID_IPersistFile,(void**)&ppf);
553 if (SUCCEEDED(res)){
555 pObj=(IUnknown*)ppf;
556 IUnknown_AddRef(pObj);
562 if (pObj!=NULL){
563 /* get the requested interface from the loaded class */
564 res= IUnknown_QueryInterface(pObj,riid,ppvResult);
566 IBindCtx_RegisterObjectBound(pbc,(IUnknown*)*ppvResult);
568 IUnknown_Release(pObj);
571 if (prot!=NULL)
572 IRunningObjectTable_Release(prot);
574 if (ppf!=NULL)
575 IPersistFile_Release(ppf);
577 if (pca!=NULL)
578 IClassActivator_Release(pca);
580 if (pcf!=NULL)
581 IClassFactory_Release(pcf);
583 return res;
586 /******************************************************************************
587 * FileMoniker_BindToStorage
589 static HRESULT WINAPI
590 FileMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
591 REFIID riid, VOID** ppvObject)
593 LPOLESTR filePath=0;
594 IStorage *pstg=0;
595 HRESULT res;
597 TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvObject);
599 if (pmkToLeft==NULL){
601 if (IsEqualIID(&IID_IStorage, riid)){
603 /* get the file name */
604 IMoniker_GetDisplayName(iface,pbc,pmkToLeft,&filePath);
606 /* verifie if the file contains a storage object */
607 res=StgIsStorageFile(filePath);
609 if(res==S_OK){
611 res=StgOpenStorage(filePath,NULL,STGM_READWRITE|STGM_SHARE_DENY_WRITE,NULL,0,&pstg);
613 if (SUCCEEDED(res)){
615 *ppvObject=pstg;
617 IStorage_AddRef(pstg);
619 return res;
622 CoTaskMemFree(filePath);
624 else
625 if ( (IsEqualIID(&IID_IStream, riid)) || (IsEqualIID(&IID_ILockBytes, riid)) )
626 return E_FAIL;
627 else
628 return E_NOINTERFACE;
630 else {
632 FIXME("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvObject);
634 return E_NOTIMPL;
636 return res;
639 /******************************************************************************
640 * FileMoniker_Reduce
641 ******************************************************************************/
642 static HRESULT WINAPI
643 FileMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar,
644 IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
646 TRACE("(%p,%p,%ld,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
648 if (ppmkReduced==NULL)
649 return E_POINTER;
651 IMoniker_AddRef(iface);
653 *ppmkReduced=iface;
655 return MK_S_REDUCED_TO_SELF;
658 /******************************************************************************
659 * FileMoniker_ComposeWith
661 static HRESULT WINAPI
662 FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
663 BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite)
665 HRESULT res;
666 LPOLESTR str1=0,str2=0,*strDec1=0,*strDec2=0,newStr=0;
667 static const WCHAR twoPoint[]={'.','.',0};
668 static const WCHAR bkSlash[]={'\\',0};
669 IBindCtx *bind=0;
670 int i=0,j=0,lastIdx1=0,lastIdx2=0;
671 DWORD mkSys;
673 TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
675 if (ppmkComposite==NULL)
676 return E_POINTER;
678 if (pmkRight==NULL)
679 return E_INVALIDARG;
681 *ppmkComposite=0;
683 IMoniker_IsSystemMoniker(pmkRight,&mkSys);
685 /* check if we have two filemonikers to compose or not */
686 if(mkSys==MKSYS_FILEMONIKER){
688 CreateBindCtx(0,&bind);
690 IMoniker_GetDisplayName(iface,bind,NULL,&str1);
691 IMoniker_GetDisplayName(pmkRight,bind,NULL,&str2);
693 /* decompose pathnames of the two monikers : (to prepare the path merge operation ) */
694 lastIdx1=FileMonikerImpl_DecomposePath(str1,&strDec1)-1;
695 lastIdx2=FileMonikerImpl_DecomposePath(str2,&strDec2)-1;
697 if ((lastIdx1==-1 && lastIdx2>-1)||(lastIdx1==1 && lstrcmpW(strDec1[0],twoPoint)==0))
698 return MK_E_SYNTAX;
700 if(lstrcmpW(strDec1[lastIdx1],bkSlash)==0)
701 lastIdx1--;
703 /* for etch "..\" in the left of str2 remove the right element from str1 */
704 for(i=0; ( (lastIdx1>=0) && (strDec2[i]!=NULL) && (lstrcmpW(strDec2[i],twoPoint)==0) ) ;i+=2){
706 lastIdx1-=2;
709 /* the length of the composed path string is raised by the sum of the two paths lengths */
710 newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
712 if (newStr==NULL)
713 return E_OUTOFMEMORY;
715 /* new path is the concatenation of the rest of str1 and str2 */
716 for(*newStr=0,j=0;j<=lastIdx1;j++)
717 strcatW(newStr,strDec1[j]);
719 if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0)
720 strcatW(newStr,bkSlash);
722 for(j=i;j<=lastIdx2;j++)
723 strcatW(newStr,strDec2[j]);
725 /* create a new moniker with the new string */
726 res=CreateFileMoniker(newStr,ppmkComposite);
728 /* free all strings space memory used by this function */
729 HeapFree(GetProcessHeap(),0,newStr);
731 for(i=0; strDec1[i]!=NULL;i++)
732 CoTaskMemFree(strDec1[i]);
733 for(i=0; strDec2[i]!=NULL;i++)
734 CoTaskMemFree(strDec2[i]);
735 CoTaskMemFree(strDec1);
736 CoTaskMemFree(strDec2);
738 CoTaskMemFree(str1);
739 CoTaskMemFree(str2);
741 return res;
743 else if(mkSys==MKSYS_ANTIMONIKER){
745 *ppmkComposite=NULL;
746 return S_OK;
748 else if (fOnlyIfNotGeneric){
750 *ppmkComposite=NULL;
751 return MK_E_NEEDGENERIC;
753 else
755 return CreateGenericComposite(iface,pmkRight,ppmkComposite);
758 /******************************************************************************
759 * FileMoniker_Enum
761 static HRESULT WINAPI
762 FileMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
764 TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker);
766 if (ppenumMoniker == NULL)
767 return E_POINTER;
769 *ppenumMoniker = NULL;
771 return S_OK;
774 /******************************************************************************
775 * FileMoniker_IsEqual
777 static HRESULT WINAPI
778 FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
780 FileMonikerImpl *This = (FileMonikerImpl *)iface;
781 CLSID clsid;
782 LPOLESTR filePath;
783 IBindCtx* bind;
784 HRESULT res;
786 TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
788 if (pmkOtherMoniker==NULL)
789 return S_FALSE;
791 IMoniker_GetClassID(pmkOtherMoniker,&clsid);
793 if (!IsEqualCLSID(&clsid,&CLSID_FileMoniker))
794 return S_FALSE;
796 res = CreateBindCtx(0,&bind);
797 if (FAILED(res)) return res;
799 if (SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath))) {
800 int result = lstrcmpiW(filePath, This->filePathName);
801 CoTaskMemFree(filePath);
802 if ( result == 0 ) return S_OK;
804 return S_FALSE;
808 /******************************************************************************
809 * FileMoniker_Hash
811 static HRESULT WINAPI
812 FileMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
814 FileMonikerImpl *This = (FileMonikerImpl *)iface;
816 int h = 0,i,skip,len;
817 int off = 0;
818 LPOLESTR val;
820 if (pdwHash==NULL)
821 return E_POINTER;
823 val = This->filePathName;
824 len = lstrlenW(val);
826 if (len < 16) {
827 for (i = len ; i > 0; i--) {
828 h = (h * 37) + val[off++];
830 } else {
831 /* only sample some characters */
832 skip = len / 8;
833 for (i = len ; i > 0; i -= skip, off += skip) {
834 h = (h * 39) + val[off];
838 *pdwHash=h;
840 return S_OK;
843 /******************************************************************************
844 * FileMoniker_IsRunning
846 static HRESULT WINAPI
847 FileMonikerImpl_IsRunning(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
848 IMoniker* pmkNewlyRunning)
850 IRunningObjectTable* rot;
851 HRESULT res;
853 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
855 if ( (pmkNewlyRunning!=NULL) && (IMoniker_IsEqual(pmkNewlyRunning,iface)==S_OK) )
856 return S_OK;
858 if (pbc==NULL)
859 return E_POINTER;
861 res=IBindCtx_GetRunningObjectTable(pbc,&rot);
863 if (FAILED(res))
864 return res;
866 res = IRunningObjectTable_IsRunning(rot,iface);
868 IRunningObjectTable_Release(rot);
870 return res;
873 /******************************************************************************
874 * FileMoniker_GetTimeOfLastChange
875 ******************************************************************************/
876 static HRESULT WINAPI
877 FileMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc,
878 IMoniker* pmkToLeft, FILETIME* pFileTime)
880 FileMonikerImpl *This = (FileMonikerImpl *)iface;
881 IRunningObjectTable* rot;
882 HRESULT res;
883 WIN32_FILE_ATTRIBUTE_DATA info;
885 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pFileTime);
887 if (pFileTime==NULL)
888 return E_POINTER;
890 if (pmkToLeft!=NULL)
891 return E_INVALIDARG;
893 res=IBindCtx_GetRunningObjectTable(pbc,&rot);
895 if (FAILED(res))
896 return res;
898 res= IRunningObjectTable_GetTimeOfLastChange(rot,iface,pFileTime);
900 if (FAILED(res)){ /* the moniker is not registered */
902 if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info))
903 return MK_E_NOOBJECT;
905 *pFileTime=info.ftLastWriteTime;
908 return S_OK;
911 /******************************************************************************
912 * FileMoniker_Inverse
914 static HRESULT WINAPI
915 FileMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
917 TRACE("(%p,%p)\n",iface,ppmk);
919 return CreateAntiMoniker(ppmk);
922 /******************************************************************************
923 * FileMoniker_CommonPrefixWith
925 static HRESULT WINAPI
926 FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
929 LPOLESTR pathThis,pathOther,*stringTable1,*stringTable2,commonPath;
930 IBindCtx *pbind;
931 DWORD mkSys;
932 ULONG nb1,nb2,i,sameIdx;
933 BOOL machimeNameCase=FALSE;
935 if (ppmkPrefix==NULL)
936 return E_POINTER;
938 if (pmkOther==NULL)
939 return E_INVALIDARG;
941 *ppmkPrefix=0;
943 /* check if we have the same type of moniker */
944 IMoniker_IsSystemMoniker(pmkOther,&mkSys);
946 if(mkSys==MKSYS_FILEMONIKER){
947 HRESULT ret;
949 CreateBindCtx(0,&pbind);
951 /* create a string based on common part of the two paths */
953 IMoniker_GetDisplayName(iface,pbind,NULL,&pathThis);
954 IMoniker_GetDisplayName(pmkOther,pbind,NULL,&pathOther);
956 nb1=FileMonikerImpl_DecomposePath(pathThis,&stringTable1);
957 nb2=FileMonikerImpl_DecomposePath(pathOther,&stringTable2);
959 if (nb1==0 || nb2==0)
960 return MK_E_NOPREFIX;
962 commonPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(min(lstrlenW(pathThis),lstrlenW(pathOther))+1));
964 *commonPath=0;
966 for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) &&
967 (stringTable2[sameIdx]!=NULL) &&
968 (lstrcmpiW(stringTable1[sameIdx],stringTable2[sameIdx])==0)); sameIdx++);
970 if (sameIdx > 1 && *stringTable1[0]=='\\' && *stringTable2[1]=='\\'){
972 machimeNameCase=TRUE;
974 for(i=2;i<sameIdx;i++)
976 if( (*stringTable1[i]=='\\') && (i+1 < sameIdx) && (*stringTable1[i+1]=='\\') ){
977 machimeNameCase=FALSE;
978 break;
982 if (machimeNameCase && *stringTable1[sameIdx-1]=='\\')
983 sameIdx--;
985 if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) )
986 ret = MK_E_NOPREFIX;
987 else
989 for(i=0;i<sameIdx;i++)
990 strcatW(commonPath,stringTable1[i]);
992 for(i=0;i<nb1;i++)
993 CoTaskMemFree(stringTable1[i]);
995 CoTaskMemFree(stringTable1);
997 for(i=0;i<nb2;i++)
998 CoTaskMemFree(stringTable2[i]);
1000 CoTaskMemFree(stringTable2);
1002 ret = CreateFileMoniker(commonPath,ppmkPrefix);
1004 HeapFree(GetProcessHeap(),0,commonPath);
1005 return ret;
1007 else
1008 return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
1011 /******************************************************************************
1012 * DecomposePath (local function)
1014 int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
1016 static const WCHAR bSlash[] = {'\\',0};
1017 WCHAR word[MAX_PATH];
1018 int i=0,j,tabIndex=0;
1019 LPOLESTR *strgtable ;
1021 int len=lstrlenW(str);
1023 TRACE("%s, %p\n", debugstr_w(str), *stringTable);
1025 strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR));
1027 if (strgtable==NULL)
1028 return E_OUTOFMEMORY;
1030 while(str[i]!=0){
1032 if(str[i]==bSlash[0]){
1034 strgtable[tabIndex]=CoTaskMemAlloc(2*sizeof(WCHAR));
1036 if (strgtable[tabIndex]==NULL)
1037 return E_OUTOFMEMORY;
1039 strcpyW(strgtable[tabIndex++],bSlash);
1041 i++;
1044 else {
1046 for(j=0; str[i]!=0 && str[i]!=bSlash[0] ; i++,j++)
1047 word[j]=str[i];
1049 word[j]=0;
1051 strgtable[tabIndex]=CoTaskMemAlloc(sizeof(WCHAR)*(j+1));
1053 if (strgtable[tabIndex]==NULL)
1054 return E_OUTOFMEMORY;
1056 strcpyW(strgtable[tabIndex++],word);
1059 strgtable[tabIndex]=NULL;
1061 *stringTable=strgtable;
1063 return tabIndex;
1066 /******************************************************************************
1067 * FileMoniker_RelativePathTo
1069 static HRESULT WINAPI
1070 FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
1072 IBindCtx *bind;
1073 HRESULT res;
1074 LPOLESTR str1=0,str2=0,*tabStr1=0,*tabStr2=0,relPath=0;
1075 DWORD len1=0,len2=0,sameIdx=0,j=0;
1076 static const WCHAR back[] ={'.','.','\\',0};
1078 TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
1080 if (ppmkRelPath==NULL)
1081 return E_POINTER;
1083 if (pmOther==NULL)
1084 return E_INVALIDARG;
1086 res=CreateBindCtx(0,&bind);
1087 if (FAILED(res))
1088 return res;
1090 res=IMoniker_GetDisplayName(iface,bind,NULL,&str1);
1091 if (FAILED(res))
1092 return res;
1093 res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2);
1094 if (FAILED(res))
1095 return res;
1097 len1=FileMonikerImpl_DecomposePath(str1,&tabStr1);
1098 len2=FileMonikerImpl_DecomposePath(str2,&tabStr2);
1100 if (FAILED(len1) || FAILED(len2))
1101 return E_OUTOFMEMORY;
1103 /* count the number of similar items from the begin of the two paths */
1104 for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) &&
1105 (tabStr2[sameIdx]!=NULL) &&
1106 (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++);
1108 /* begin the construction of relativePath */
1109 /* if the two paths have a consecutive similar item from the begin ! the relativePath will be composed */
1110 /* by "..\\" in the begin */
1111 relPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(1+lstrlenW(str1)+lstrlenW(str2)));
1113 *relPath=0;
1115 if (len2>0 && !(len1==1 && len2==1 && sameIdx==0))
1116 for(j=sameIdx;(tabStr1[j] != NULL); j++)
1117 if (*tabStr1[j]!='\\')
1118 strcatW(relPath,back);
1120 /* add items of the second path (similar items with the first path are not included) to the relativePath */
1121 for(j=sameIdx;tabStr2[j]!=NULL;j++)
1122 strcatW(relPath,tabStr2[j]);
1124 res=CreateFileMoniker(relPath,ppmkRelPath);
1126 for(j=0; tabStr1[j]!=NULL;j++)
1127 CoTaskMemFree(tabStr1[j]);
1128 for(j=0; tabStr2[j]!=NULL;j++)
1129 CoTaskMemFree(tabStr2[j]);
1130 CoTaskMemFree(tabStr1);
1131 CoTaskMemFree(tabStr2);
1132 CoTaskMemFree(str1);
1133 CoTaskMemFree(str2);
1134 HeapFree(GetProcessHeap(),0,relPath);
1136 if (len1==0 || len2==0 || (len1==1 && len2==1 && sameIdx==0))
1137 return MK_S_HIM;
1139 return res;
1142 /******************************************************************************
1143 * FileMoniker_GetDisplayName
1145 static HRESULT WINAPI
1146 FileMonikerImpl_GetDisplayName(IMoniker* iface, IBindCtx* pbc,
1147 IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
1149 FileMonikerImpl *This = (FileMonikerImpl *)iface;
1151 int len=lstrlenW(This->filePathName);
1153 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
1155 if (ppszDisplayName==NULL)
1156 return E_POINTER;
1158 if (pmkToLeft!=NULL)
1159 return E_INVALIDARG;
1161 *ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR)*(len+1));
1162 if (*ppszDisplayName==NULL)
1163 return E_OUTOFMEMORY;
1165 strcpyW(*ppszDisplayName,This->filePathName);
1167 TRACE("-- %s\n", debugstr_w(*ppszDisplayName));
1169 return S_OK;
1172 /******************************************************************************
1173 * FileMoniker_ParseDisplayName
1175 static HRESULT WINAPI
1176 FileMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
1177 LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
1179 FIXME("(%p,%p,%p,%p,%p,%p),stub!\n",iface,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
1180 return E_NOTIMPL;
1183 /******************************************************************************
1184 * FileMoniker_IsSystemMoniker
1186 static HRESULT WINAPI
1187 FileMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
1189 TRACE("(%p,%p)\n",iface,pwdMksys);
1191 if (!pwdMksys)
1192 return E_POINTER;
1194 (*pwdMksys)=MKSYS_FILEMONIKER;
1196 return S_OK;
1199 /*******************************************************************************
1200 * FileMonikerIROTData_QueryInterface
1202 static HRESULT WINAPI
1203 FileMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
1206 IMoniker *This = impl_from_IROTData(iface);
1208 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
1210 return FileMonikerImpl_QueryInterface(This, riid, ppvObject);
1213 /***********************************************************************
1214 * FileMonikerIROTData_AddRef
1216 static ULONG WINAPI
1217 FileMonikerROTDataImpl_AddRef(IROTData *iface)
1219 IMoniker *This = impl_from_IROTData(iface);
1221 TRACE("(%p)\n",This);
1223 return IMoniker_AddRef(This);
1226 /***********************************************************************
1227 * FileMonikerIROTData_Release
1229 static ULONG WINAPI
1230 FileMonikerROTDataImpl_Release(IROTData* iface)
1232 IMoniker *This = impl_from_IROTData(iface);
1234 TRACE("(%p)\n",This);
1236 return FileMonikerImpl_Release(This);
1239 /******************************************************************************
1240 * FileMonikerIROTData_GetComparaisonData
1242 static HRESULT WINAPI
1243 FileMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
1244 ULONG cbMax, ULONG* pcbData)
1246 IMoniker *This = impl_from_IROTData(iface);
1247 FileMonikerImpl *This1 = (FileMonikerImpl *)This;
1248 int len = (strlenW(This1->filePathName)+1);
1249 int i;
1250 LPWSTR pszFileName;
1252 TRACE("(%p, %lu, %p)\n", pbData, cbMax, pcbData);
1254 *pcbData = sizeof(CLSID) + len * sizeof(WCHAR);
1255 if (cbMax < *pcbData)
1256 return E_OUTOFMEMORY;
1258 memcpy(pbData, &CLSID_FileMoniker, sizeof(CLSID));
1259 pszFileName = (LPWSTR)(pbData+sizeof(CLSID));
1260 for (i = 0; i < len; i++)
1261 pszFileName[i] = toupperW(This1->filePathName[i]);
1263 return S_OK;
1267 * Virtual function table for the FileMonikerImpl class which include IPersist,
1268 * IPersistStream and IMoniker functions.
1270 static const IMonikerVtbl VT_FileMonikerImpl =
1272 FileMonikerImpl_QueryInterface,
1273 FileMonikerImpl_AddRef,
1274 FileMonikerImpl_Release,
1275 FileMonikerImpl_GetClassID,
1276 FileMonikerImpl_IsDirty,
1277 FileMonikerImpl_Load,
1278 FileMonikerImpl_Save,
1279 FileMonikerImpl_GetSizeMax,
1280 FileMonikerImpl_BindToObject,
1281 FileMonikerImpl_BindToStorage,
1282 FileMonikerImpl_Reduce,
1283 FileMonikerImpl_ComposeWith,
1284 FileMonikerImpl_Enum,
1285 FileMonikerImpl_IsEqual,
1286 FileMonikerImpl_Hash,
1287 FileMonikerImpl_IsRunning,
1288 FileMonikerImpl_GetTimeOfLastChange,
1289 FileMonikerImpl_Inverse,
1290 FileMonikerImpl_CommonPrefixWith,
1291 FileMonikerImpl_RelativePathTo,
1292 FileMonikerImpl_GetDisplayName,
1293 FileMonikerImpl_ParseDisplayName,
1294 FileMonikerImpl_IsSystemMoniker
1297 /* Virtual function table for the IROTData class. */
1298 static const IROTDataVtbl VT_ROTDataImpl =
1300 FileMonikerROTDataImpl_QueryInterface,
1301 FileMonikerROTDataImpl_AddRef,
1302 FileMonikerROTDataImpl_Release,
1303 FileMonikerROTDataImpl_GetComparisonData
1306 /******************************************************************************
1307 * FileMoniker_Construct (local function)
1309 static HRESULT WINAPI
1310 FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPathName)
1312 int nb=0,i;
1313 int sizeStr=lstrlenW(lpszPathName);
1314 LPOLESTR *tabStr=0;
1315 static const WCHAR twoPoint[]={'.','.',0};
1316 static const WCHAR bkSlash[]={'\\',0};
1317 BYTE addBkSlash;
1319 TRACE("(%p,%s)\n",This,debugstr_w(lpszPathName));
1321 /* Initialize the virtual fgunction table. */
1322 This->lpvtbl1 = &VT_FileMonikerImpl;
1323 This->lpvtbl2 = &VT_ROTDataImpl;
1324 This->ref = 0;
1325 This->pMarshal = NULL;
1327 This->filePathName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr+1));
1329 if (This->filePathName==NULL)
1330 return E_OUTOFMEMORY;
1332 strcpyW(This->filePathName,lpszPathName);
1334 nb=FileMonikerImpl_DecomposePath(This->filePathName,&tabStr);
1336 if (nb > 0 ){
1338 addBkSlash=1;
1339 if (lstrcmpW(tabStr[0],twoPoint)!=0)
1340 addBkSlash=0;
1341 else
1342 for(i=0;i<nb;i++){
1344 if ( (lstrcmpW(tabStr[i],twoPoint)!=0) && (lstrcmpW(tabStr[i],bkSlash)!=0) ){
1345 addBkSlash=0;
1346 break;
1348 else
1350 if (lstrcmpW(tabStr[i],bkSlash)==0 && i<nb-1 && lstrcmpW(tabStr[i+1],bkSlash)==0){
1351 *tabStr[i]=0;
1352 sizeStr--;
1353 addBkSlash=0;
1354 break;
1358 if (lstrcmpW(tabStr[nb-1],bkSlash)==0)
1359 addBkSlash=0;
1361 This->filePathName=HeapReAlloc(GetProcessHeap(),0,This->filePathName,(sizeStr+1)*sizeof(WCHAR));
1363 *This->filePathName=0;
1365 for(i=0;tabStr[i]!=NULL;i++)
1366 strcatW(This->filePathName,tabStr[i]);
1368 if (addBkSlash)
1369 strcatW(This->filePathName,bkSlash);
1372 for(i=0; tabStr[i]!=NULL;i++)
1373 CoTaskMemFree(tabStr[i]);
1374 CoTaskMemFree(tabStr);
1376 return S_OK;
1379 /******************************************************************************
1380 * CreateFileMoniker (OLE32.@)
1381 ******************************************************************************/
1382 HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, LPMONIKER * ppmk)
1384 FileMonikerImpl* newFileMoniker;
1385 HRESULT hr;
1387 TRACE("(%s,%p)\n",debugstr_w(lpszPathName),ppmk);
1389 if (!ppmk)
1390 return E_POINTER;
1392 if(!lpszPathName)
1393 return MK_E_SYNTAX;
1395 *ppmk=NULL;
1397 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
1399 if (!newFileMoniker)
1400 return E_OUTOFMEMORY;
1402 hr = FileMonikerImpl_Construct(newFileMoniker,lpszPathName);
1404 if (SUCCEEDED(hr))
1405 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&IID_IMoniker,(void**)ppmk);
1406 else
1407 HeapFree(GetProcessHeap(),0,newFileMoniker);
1409 return hr;
1412 static HRESULT WINAPI FileMonikerCF_QueryInterface(LPCLASSFACTORY iface,
1413 REFIID riid, LPVOID *ppv)
1415 *ppv = NULL;
1416 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
1418 *ppv = iface;
1419 IUnknown_AddRef(iface);
1420 return S_OK;
1422 return E_NOINTERFACE;
1425 static ULONG WINAPI FileMonikerCF_AddRef(LPCLASSFACTORY iface)
1427 return 2; /* non-heap based object */
1430 static ULONG WINAPI FileMonikerCF_Release(LPCLASSFACTORY iface)
1432 return 1; /* non-heap based object */
1435 static HRESULT WINAPI FileMonikerCF_CreateInstance(LPCLASSFACTORY iface,
1436 LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
1438 FileMonikerImpl* newFileMoniker;
1439 HRESULT hr;
1440 static const WCHAR wszEmpty[] = { 0 };
1442 TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
1444 *ppv = NULL;
1446 if (pUnk)
1447 return CLASS_E_NOAGGREGATION;
1449 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
1450 if (!newFileMoniker)
1451 return E_OUTOFMEMORY;
1453 hr = FileMonikerImpl_Construct(newFileMoniker, wszEmpty);
1455 if (SUCCEEDED(hr))
1456 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker, riid, ppv);
1457 if (FAILED(hr))
1458 HeapFree(GetProcessHeap(),0,newFileMoniker);
1460 return hr;
1463 static HRESULT WINAPI FileMonikerCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
1465 FIXME("(%d), stub!\n",fLock);
1466 return S_OK;
1469 static const IClassFactoryVtbl FileMonikerCFVtbl =
1471 FileMonikerCF_QueryInterface,
1472 FileMonikerCF_AddRef,
1473 FileMonikerCF_Release,
1474 FileMonikerCF_CreateInstance,
1475 FileMonikerCF_LockServer
1477 static const IClassFactoryVtbl *FileMonikerCF = &FileMonikerCFVtbl;
1479 HRESULT FileMonikerCF_Create(REFIID riid, LPVOID *ppv)
1481 return IClassFactory_QueryInterface((IClassFactory *)&FileMonikerCF, riid, ppv);