Fix gcc 4.0 -Wpointer-sign warnings.
[wine/testsucceed.git] / dlls / ole32 / filemoniker.c
bloba4e6a73a3bbe982b04841815b59a68d0a0d5ec3b
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 /* Local function used by filemoniker implementation */
64 static HRESULT WINAPI FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName);
65 static HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* iface);
67 /*******************************************************************************
68 * FileMoniker_QueryInterface
70 static HRESULT WINAPI
71 FileMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
73 FileMonikerImpl *This = (FileMonikerImpl *)iface;
75 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
77 /* Perform a sanity check on the parameters.*/
78 if ( (This==0) || (ppvObject==0) )
79 return E_INVALIDARG;
81 /* Initialize the return parameter */
82 *ppvObject = 0;
84 /* Compare the riid with the interface IDs implemented by this object.*/
85 if (IsEqualIID(&IID_IUnknown, riid) ||
86 IsEqualIID(&IID_IPersist, riid) ||
87 IsEqualIID(&IID_IPersistStream,riid) ||
88 IsEqualIID(&IID_IMoniker, riid)
90 *ppvObject = iface;
92 else if (IsEqualIID(&IID_IROTData, riid))
93 *ppvObject = (IROTData*)&(This->lpvtbl2);
94 else if (IsEqualIID(&IID_IMarshal, riid))
96 HRESULT hr = S_OK;
97 if (!This->pMarshal)
98 hr = MonikerMarshal_Create(iface, &This->pMarshal);
99 if (hr != S_OK)
100 return hr;
101 return IUnknown_QueryInterface(This->pMarshal, riid, ppvObject);
104 /* Check that we obtained an interface.*/
105 if ((*ppvObject)==0)
106 return E_NOINTERFACE;
108 /* Query Interface always increases the reference count by one when it is successful */
109 IMoniker_AddRef(iface);
111 return S_OK;
114 /******************************************************************************
115 * FileMoniker_AddRef
117 static ULONG WINAPI
118 FileMonikerImpl_AddRef(IMoniker* iface)
120 FileMonikerImpl *This = (FileMonikerImpl *)iface;
122 TRACE("(%p)\n",iface);
124 return InterlockedIncrement(&This->ref);
127 /******************************************************************************
128 * FileMoniker_Release
130 static ULONG WINAPI
131 FileMonikerImpl_Release(IMoniker* iface)
133 FileMonikerImpl *This = (FileMonikerImpl *)iface;
134 ULONG ref;
136 TRACE("(%p)\n",iface);
138 ref = InterlockedDecrement(&This->ref);
140 /* destroy the object if there's no more reference on it */
141 if (ref == 0) FileMonikerImpl_Destroy(This);
143 return ref;
146 /******************************************************************************
147 * FileMoniker_GetClassID
149 static HRESULT WINAPI
150 FileMonikerImpl_GetClassID(IMoniker* iface, CLSID *pClassID)
152 TRACE("(%p,%p)\n",iface,pClassID);
154 if (pClassID==NULL)
155 return E_POINTER;
157 *pClassID = CLSID_FileMoniker;
159 return S_OK;
162 /******************************************************************************
163 * FileMoniker_IsDirty
165 * Note that the OLE-provided implementations of the IPersistStream::IsDirty
166 * method in the OLE-provided moniker interfaces always return S_FALSE because
167 * their internal state never changes.
169 static HRESULT WINAPI
170 FileMonikerImpl_IsDirty(IMoniker* iface)
173 TRACE("(%p)\n",iface);
175 return S_FALSE;
178 /******************************************************************************
179 * FileMoniker_Load
181 * this function locates and reads from the stream the filePath string
182 * written by FileMonikerImpl_Save
184 static HRESULT WINAPI
185 FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
187 HRESULT res;
188 CHAR* filePathA = NULL;
189 WCHAR* filePathW = NULL;
190 ULONG bread;
191 WORD wbuffer;
192 DWORD dwbuffer, bytesA, bytesW, len;
193 int i;
195 FileMonikerImpl *This = (FileMonikerImpl *)iface;
197 TRACE("(%p,%p)\n",iface,pStm);
199 /* first WORD must be 0 */
200 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
201 if (bread!=sizeof(WORD) || wbuffer!=0)
203 WARN("Couldn't read 0 word\n");
204 goto fail;
207 /* read filePath string length (plus one) */
208 res=IStream_Read(pStm,&bytesA,sizeof(DWORD),&bread);
209 if (bread != sizeof(DWORD))
211 WARN("Couldn't read file string length\n");
212 goto fail;
215 /* read filePath string */
216 filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
217 if (!filePathA)
219 res = E_OUTOFMEMORY;
220 goto fail;
223 res=IStream_Read(pStm,filePathA,bytesA,&bread);
224 if (bread != bytesA)
226 WARN("Couldn't read file path string\n");
227 goto fail;
230 /* read the first constant */
231 IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
232 if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF)
234 WARN("Couldn't read 0xDEADFFFF constant\n");
235 goto fail;
238 for(i=0;i<5;i++)
240 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
241 if (bread!=sizeof(DWORD) || dwbuffer!=0)
243 WARN("Couldn't read 0 padding\n");
244 goto fail;
248 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
249 if (bread!=sizeof(DWORD))
250 goto fail;
252 if (!dwbuffer) /* No W-string */
254 bytesA--;
255 len=MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, bytesA, NULL, 0);
256 if (!len)
257 goto fail;
259 filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
260 if (!filePathW)
262 res = E_OUTOFMEMORY;
263 goto fail;
265 MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, -1, filePathW, len+1);
266 goto succeed;
269 if (dwbuffer < 6)
270 goto fail;
272 bytesW=dwbuffer - 6;
274 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
275 if (bread!=sizeof(DWORD) || dwbuffer!=bytesW)
276 goto fail;
278 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
279 if (bread!=sizeof(WORD) || wbuffer!=0x3)
280 goto fail;
282 len=bytesW/sizeof(WCHAR);
283 filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
284 if(!filePathW)
286 res = E_OUTOFMEMORY;
287 goto fail;
289 res=IStream_Read(pStm,filePathW,bytesW,&bread);
290 if (bread!=bytesW)
291 goto fail;
293 filePathW[len]=0;
295 succeed:
296 HeapFree(GetProcessHeap(),0,filePathA);
297 HeapFree(GetProcessHeap(),0,This->filePathName);
298 This->filePathName=filePathW;
300 return S_OK;
302 fail:
303 HeapFree(GetProcessHeap(), 0, filePathA);
304 HeapFree(GetProcessHeap(), 0, filePathW);
306 if (SUCCEEDED(res))
307 res = E_FAIL;
308 return res;
311 /******************************************************************************
312 * FileMoniker_Save
314 * This function saves data of this object. In the beginning I thought
315 * that I have just to write the filePath string on Stream. But, when I
316 * tested this function with windows programs samples, I noticed that it
317 * was not the case. This implementation is based on XP SP2. Other versions
318 * of Windows have minor variations.
320 * Data which must be written on stream is:
321 * 1) WORD constant:zero
322 * 2) length of the path string ("\0" included)
323 * 3) path string type A
324 * 4) DWORD constant : 0xDEADFFFF
325 * 5) five DWORD constant: zero
326 * 6) If we're only writing the multibyte version,
327 * write a zero DWORD and finish.
329 * 7) DWORD: double-length of the the path string type W ("\0" not
330 * included)
331 * 8) WORD constant: 0x3
332 * 9) filePath unicode string.
335 static HRESULT WINAPI
336 FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
338 FileMonikerImpl *This = (FileMonikerImpl *)iface;
340 HRESULT res;
341 LPOLESTR filePathW=This->filePathName;
342 CHAR* filePathA;
343 DWORD bytesA, bytesW, len;
345 static const DWORD DEADFFFF = 0xDEADFFFF; /* Constants */
346 static const DWORD ZERO = 0;
347 static const WORD THREE = 0x3;
349 int i;
350 BOOL bUsedDefault, bWriteWide;
352 TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
354 if (pStm==NULL)
355 return E_POINTER;
357 /* write a 0 WORD */
358 res=IStream_Write(pStm,&ZERO,sizeof(WORD),NULL);
359 if (!SUCCEEDED(res)) return res;
361 /* write length of filePath string ( 0 included )*/
362 bytesA = WideCharToMultiByte( CP_ACP, 0, filePathW, -1, NULL, 0, NULL, NULL );
363 res=IStream_Write(pStm,&bytesA,sizeof(DWORD),NULL);
364 if (!SUCCEEDED(res)) return res;
366 /* write A string (with '\0') */
367 filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
368 if (!filePathA)
369 return E_OUTOFMEMORY;
370 WideCharToMultiByte( CP_ACP, 0, filePathW, -1, filePathA, bytesA, NULL, &bUsedDefault);
371 res=IStream_Write(pStm,filePathA,bytesA,NULL);
372 HeapFree(GetProcessHeap(),0,filePathA);
373 if (!SUCCEEDED(res)) return res;
375 /* write a DWORD 0xDEADFFFF */
376 res=IStream_Write(pStm,&DEADFFFF,sizeof(DWORD),NULL);
377 if (!SUCCEEDED(res)) return res;
379 /* write 5 zero DWORDs */
380 for(i=0;i<5;i++)
382 res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
383 if (!SUCCEEDED(res)) return res;
386 /* Write the wide version if:
387 * + couldn't convert to CP_ACP,
388 * or + it's a directory,
389 * or + there's a character > 0xFF
391 len = lstrlenW(filePathW);
392 bWriteWide = (bUsedDefault || (len > 0 && filePathW[len-1]=='\\' ));
393 if (!bWriteWide)
395 WCHAR* pch;
396 for(pch=filePathW;*pch;++pch)
398 if (*pch > 0xFF)
400 bWriteWide = TRUE;
401 break;
406 if (!bWriteWide)
408 res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
409 return res;
412 /* write bytes needed for the filepathW (without 0) + 6 */
413 bytesW = len*sizeof(WCHAR) + 6;
414 res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
415 if (!SUCCEEDED(res)) return res;
417 /* try again, without the extra 6 */
418 bytesW -= 6;
419 res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
420 if (!SUCCEEDED(res)) return res;
422 /* write a WORD 3 */
423 res=IStream_Write(pStm,&THREE,sizeof(WORD),NULL);
424 if (!SUCCEEDED(res)) return res;
426 /* write W string (no 0) */
427 res=IStream_Write(pStm,filePathW,bytesW,NULL);
429 return res;
432 /******************************************************************************
433 * FileMoniker_GetSizeMax
435 static HRESULT WINAPI
436 FileMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
438 FileMonikerImpl *This = (FileMonikerImpl *)iface;
440 TRACE("(%p,%p)\n",iface,pcbSize);
442 if (!pcbSize)
443 return E_POINTER;
445 /* We could calculate exactly (see ...::Save()) but instead
446 * we'll make a quick over-estimate, like Windows (NT4, XP) does.
448 pcbSize->u.LowPart = 0x38 + 4 * lstrlenW(This->filePathName);
449 pcbSize->u.HighPart = 0;
451 return S_OK;
454 /******************************************************************************
455 * FileMoniker_Destroy (local function)
456 *******************************************************************************/
457 HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* This)
459 TRACE("(%p)\n",This);
461 if (This->pMarshal) IUnknown_Release(This->pMarshal);
462 HeapFree(GetProcessHeap(),0,This->filePathName);
463 HeapFree(GetProcessHeap(),0,This);
465 return S_OK;
468 /******************************************************************************
469 * FileMoniker_BindToObject
471 static HRESULT WINAPI
472 FileMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
473 REFIID riid, VOID** ppvResult)
475 HRESULT res=E_FAIL;
476 CLSID clsID;
477 IUnknown* pObj=0;
478 IRunningObjectTable *prot=0;
479 IPersistFile *ppf=0;
480 IClassFactory *pcf=0;
481 IClassActivator *pca=0;
483 FileMonikerImpl *This = (FileMonikerImpl *)iface;
485 *ppvResult=0;
487 TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
489 if(pmkToLeft==NULL){
491 res=IBindCtx_GetRunningObjectTable(pbc,&prot);
493 if (SUCCEEDED(res)){
494 /* if the requested class was loaded before ! we don't need to reload it */
495 res = IRunningObjectTable_GetObject(prot,iface,&pObj);
497 if (res==S_FALSE){
498 /* first activation of this class */
499 res=GetClassFile(This->filePathName,&clsID);
500 if (SUCCEEDED(res)){
502 res=CoCreateInstance(&clsID,NULL,CLSCTX_ALL,&IID_IPersistFile,(void**)&ppf);
503 if (SUCCEEDED(res)){
505 res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
506 if (SUCCEEDED(res)){
508 pObj=(IUnknown*)ppf;
509 IUnknown_AddRef(pObj);
516 else{
517 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassFactory,(void**)&pcf);
519 if (res==E_NOINTERFACE){
521 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca);
523 if (res==E_NOINTERFACE)
524 return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED;
526 if (pcf!=NULL){
528 IClassFactory_CreateInstance(pcf,NULL,&IID_IPersistFile,(void**)ppf);
530 res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
532 if (SUCCEEDED(res)){
534 pObj=(IUnknown*)ppf;
535 IUnknown_AddRef(pObj);
538 if (pca!=NULL){
540 FIXME("()\n");
542 /*res=GetClassFile(This->filePathName,&clsID);
544 if (SUCCEEDED(res)){
546 res=IClassActivator_GetClassObject(pca,&clsID,CLSCTX_ALL,0,&IID_IPersistFile,(void**)&ppf);
548 if (SUCCEEDED(res)){
550 pObj=(IUnknown*)ppf;
551 IUnknown_AddRef(pObj);
557 if (pObj!=NULL){
558 /* get the requested interface from the loaded class */
559 res= IUnknown_QueryInterface(pObj,riid,ppvResult);
561 IBindCtx_RegisterObjectBound(pbc,(IUnknown*)*ppvResult);
563 IUnknown_Release(pObj);
566 if (prot!=NULL)
567 IRunningObjectTable_Release(prot);
569 if (ppf!=NULL)
570 IPersistFile_Release(ppf);
572 if (pca!=NULL)
573 IClassActivator_Release(pca);
575 if (pcf!=NULL)
576 IClassFactory_Release(pcf);
578 return res;
581 /******************************************************************************
582 * FileMoniker_BindToStorage
584 static HRESULT WINAPI
585 FileMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
586 REFIID riid, VOID** ppvObject)
588 LPOLESTR filePath=0;
589 IStorage *pstg=0;
590 HRESULT res;
592 TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvObject);
594 if (pmkToLeft==NULL){
596 if (IsEqualIID(&IID_IStorage, riid)){
598 /* get the file name */
599 IMoniker_GetDisplayName(iface,pbc,pmkToLeft,&filePath);
601 /* verifie if the file contains a storage object */
602 res=StgIsStorageFile(filePath);
604 if(res==S_OK){
606 res=StgOpenStorage(filePath,NULL,STGM_READWRITE|STGM_SHARE_DENY_WRITE,NULL,0,&pstg);
608 if (SUCCEEDED(res)){
610 *ppvObject=pstg;
612 IStorage_AddRef(pstg);
614 return res;
617 CoTaskMemFree(filePath);
619 else
620 if ( (IsEqualIID(&IID_IStream, riid)) || (IsEqualIID(&IID_ILockBytes, riid)) )
621 return E_FAIL;
622 else
623 return E_NOINTERFACE;
625 else {
627 FIXME("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvObject);
629 return E_NOTIMPL;
631 return res;
634 /******************************************************************************
635 * FileMoniker_Reduce
636 ******************************************************************************/
637 static HRESULT WINAPI
638 FileMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar,
639 IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
641 TRACE("(%p,%p,%ld,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
643 if (ppmkReduced==NULL)
644 return E_POINTER;
646 IMoniker_AddRef(iface);
648 *ppmkReduced=iface;
650 return MK_S_REDUCED_TO_SELF;
653 /******************************************************************************
654 * FileMoniker_ComposeWith
656 static HRESULT WINAPI
657 FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
658 BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite)
660 HRESULT res;
661 LPOLESTR str1=0,str2=0,*strDec1=0,*strDec2=0,newStr=0;
662 static const WCHAR twoPoint[]={'.','.',0};
663 static const WCHAR bkSlash[]={'\\',0};
664 IBindCtx *bind=0;
665 int i=0,j=0,lastIdx1=0,lastIdx2=0;
666 DWORD mkSys;
668 TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
670 if (ppmkComposite==NULL)
671 return E_POINTER;
673 if (pmkRight==NULL)
674 return E_INVALIDARG;
676 *ppmkComposite=0;
678 IMoniker_IsSystemMoniker(pmkRight,&mkSys);
680 /* check if we have two filemonikers to compose or not */
681 if(mkSys==MKSYS_FILEMONIKER){
683 CreateBindCtx(0,&bind);
685 IMoniker_GetDisplayName(iface,bind,NULL,&str1);
686 IMoniker_GetDisplayName(pmkRight,bind,NULL,&str2);
688 /* decompose pathnames of the two monikers : (to prepare the path merge operation ) */
689 lastIdx1=FileMonikerImpl_DecomposePath(str1,&strDec1)-1;
690 lastIdx2=FileMonikerImpl_DecomposePath(str2,&strDec2)-1;
692 if ((lastIdx1==-1 && lastIdx2>-1)||(lastIdx1==1 && lstrcmpW(strDec1[0],twoPoint)==0))
693 return MK_E_SYNTAX;
695 if(lstrcmpW(strDec1[lastIdx1],bkSlash)==0)
696 lastIdx1--;
698 /* for etch "..\" in the left of str2 remove the right element from str1 */
699 for(i=0; ( (lastIdx1>=0) && (strDec2[i]!=NULL) && (lstrcmpW(strDec2[i],twoPoint)==0) ) ;i+=2){
701 lastIdx1-=2;
704 /* the length of the composed path string is raised by the sum of the two paths lengths */
705 newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
707 if (newStr==NULL)
708 return E_OUTOFMEMORY;
710 /* new path is the concatenation of the rest of str1 and str2 */
711 for(*newStr=0,j=0;j<=lastIdx1;j++)
712 strcatW(newStr,strDec1[j]);
714 if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0)
715 strcatW(newStr,bkSlash);
717 for(j=i;j<=lastIdx2;j++)
718 strcatW(newStr,strDec2[j]);
720 /* create a new moniker with the new string */
721 res=CreateFileMoniker(newStr,ppmkComposite);
723 /* free all strings space memory used by this function */
724 HeapFree(GetProcessHeap(),0,newStr);
726 for(i=0; strDec1[i]!=NULL;i++)
727 CoTaskMemFree(strDec1[i]);
728 for(i=0; strDec2[i]!=NULL;i++)
729 CoTaskMemFree(strDec2[i]);
730 CoTaskMemFree(strDec1);
731 CoTaskMemFree(strDec2);
733 CoTaskMemFree(str1);
734 CoTaskMemFree(str2);
736 return res;
738 else if(mkSys==MKSYS_ANTIMONIKER){
740 *ppmkComposite=NULL;
741 return S_OK;
743 else if (fOnlyIfNotGeneric){
745 *ppmkComposite=NULL;
746 return MK_E_NEEDGENERIC;
748 else
750 return CreateGenericComposite(iface,pmkRight,ppmkComposite);
753 /******************************************************************************
754 * FileMoniker_Enum
756 static HRESULT WINAPI
757 FileMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
759 TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker);
761 if (ppenumMoniker == NULL)
762 return E_POINTER;
764 *ppenumMoniker = NULL;
766 return S_OK;
769 /******************************************************************************
770 * FileMoniker_IsEqual
772 static HRESULT WINAPI
773 FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
775 FileMonikerImpl *This = (FileMonikerImpl *)iface;
776 CLSID clsid;
777 LPOLESTR filePath;
778 IBindCtx* bind;
779 HRESULT res;
781 TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
783 if (pmkOtherMoniker==NULL)
784 return S_FALSE;
786 IMoniker_GetClassID(pmkOtherMoniker,&clsid);
788 if (!IsEqualCLSID(&clsid,&CLSID_FileMoniker))
789 return S_FALSE;
791 res = CreateBindCtx(0,&bind);
792 if (FAILED(res)) return res;
794 if (SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath))) {
795 int result = lstrcmpiW(filePath, This->filePathName);
796 CoTaskMemFree(filePath);
797 if ( result == 0 ) return S_OK;
799 return S_FALSE;
803 /******************************************************************************
804 * FileMoniker_Hash
806 static HRESULT WINAPI
807 FileMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
809 FileMonikerImpl *This = (FileMonikerImpl *)iface;
811 int h = 0,i,skip,len;
812 int off = 0;
813 LPOLESTR val;
815 if (pdwHash==NULL)
816 return E_POINTER;
818 val = This->filePathName;
819 len = lstrlenW(val);
821 if (len < 16) {
822 for (i = len ; i > 0; i--) {
823 h = (h * 37) + val[off++];
825 } else {
826 /* only sample some characters */
827 skip = len / 8;
828 for (i = len ; i > 0; i -= skip, off += skip) {
829 h = (h * 39) + val[off];
833 *pdwHash=h;
835 return S_OK;
838 /******************************************************************************
839 * FileMoniker_IsRunning
841 static HRESULT WINAPI
842 FileMonikerImpl_IsRunning(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
843 IMoniker* pmkNewlyRunning)
845 IRunningObjectTable* rot;
846 HRESULT res;
848 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
850 if ( (pmkNewlyRunning!=NULL) && (IMoniker_IsEqual(pmkNewlyRunning,iface)==S_OK) )
851 return S_OK;
853 if (pbc==NULL)
854 return E_POINTER;
856 res=IBindCtx_GetRunningObjectTable(pbc,&rot);
858 if (FAILED(res))
859 return res;
861 res = IRunningObjectTable_IsRunning(rot,iface);
863 IRunningObjectTable_Release(rot);
865 return res;
868 /******************************************************************************
869 * FileMoniker_GetTimeOfLastChange
870 ******************************************************************************/
871 static HRESULT WINAPI
872 FileMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc,
873 IMoniker* pmkToLeft, FILETIME* pFileTime)
875 FileMonikerImpl *This = (FileMonikerImpl *)iface;
876 IRunningObjectTable* rot;
877 HRESULT res;
878 WIN32_FILE_ATTRIBUTE_DATA info;
880 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pFileTime);
882 if (pFileTime==NULL)
883 return E_POINTER;
885 if (pmkToLeft!=NULL)
886 return E_INVALIDARG;
888 res=IBindCtx_GetRunningObjectTable(pbc,&rot);
890 if (FAILED(res))
891 return res;
893 res= IRunningObjectTable_GetTimeOfLastChange(rot,iface,pFileTime);
895 if (FAILED(res)){ /* the moniker is not registered */
897 if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info))
898 return MK_E_NOOBJECT;
900 *pFileTime=info.ftLastWriteTime;
903 return S_OK;
906 /******************************************************************************
907 * FileMoniker_Inverse
909 static HRESULT WINAPI
910 FileMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
912 TRACE("(%p,%p)\n",iface,ppmk);
914 return CreateAntiMoniker(ppmk);
917 /******************************************************************************
918 * FileMoniker_CommonPrefixWith
920 static HRESULT WINAPI
921 FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
924 LPOLESTR pathThis,pathOther,*stringTable1,*stringTable2,commonPath;
925 IBindCtx *pbind;
926 DWORD mkSys;
927 ULONG nb1,nb2,i,sameIdx;
928 BOOL machimeNameCase=FALSE;
930 if (ppmkPrefix==NULL)
931 return E_POINTER;
933 if (pmkOther==NULL)
934 return E_INVALIDARG;
936 *ppmkPrefix=0;
938 /* check if we have the same type of moniker */
939 IMoniker_IsSystemMoniker(pmkOther,&mkSys);
941 if(mkSys==MKSYS_FILEMONIKER){
942 HRESULT ret;
944 CreateBindCtx(0,&pbind);
946 /* create a string based on common part of the two paths */
948 IMoniker_GetDisplayName(iface,pbind,NULL,&pathThis);
949 IMoniker_GetDisplayName(pmkOther,pbind,NULL,&pathOther);
951 nb1=FileMonikerImpl_DecomposePath(pathThis,&stringTable1);
952 nb2=FileMonikerImpl_DecomposePath(pathOther,&stringTable2);
954 if (nb1==0 || nb2==0)
955 return MK_E_NOPREFIX;
957 commonPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(min(lstrlenW(pathThis),lstrlenW(pathOther))+1));
959 *commonPath=0;
961 for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) &&
962 (stringTable2[sameIdx]!=NULL) &&
963 (lstrcmpiW(stringTable1[sameIdx],stringTable2[sameIdx])==0)); sameIdx++);
965 if (sameIdx > 1 && *stringTable1[0]=='\\' && *stringTable2[1]=='\\'){
967 machimeNameCase=TRUE;
969 for(i=2;i<sameIdx;i++)
971 if( (*stringTable1[i]=='\\') && (i+1 < sameIdx) && (*stringTable1[i+1]=='\\') ){
972 machimeNameCase=FALSE;
973 break;
977 if (machimeNameCase && *stringTable1[sameIdx-1]=='\\')
978 sameIdx--;
980 if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) )
981 ret = MK_E_NOPREFIX;
982 else
984 for(i=0;i<sameIdx;i++)
985 strcatW(commonPath,stringTable1[i]);
987 for(i=0;i<nb1;i++)
988 CoTaskMemFree(stringTable1[i]);
990 CoTaskMemFree(stringTable1);
992 for(i=0;i<nb2;i++)
993 CoTaskMemFree(stringTable2[i]);
995 CoTaskMemFree(stringTable2);
997 ret = CreateFileMoniker(commonPath,ppmkPrefix);
999 HeapFree(GetProcessHeap(),0,commonPath);
1000 return ret;
1002 else
1003 return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
1006 /******************************************************************************
1007 * DecomposePath (local function)
1009 int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
1011 static const WCHAR bSlash[] = {'\\',0};
1012 WCHAR word[MAX_PATH];
1013 int i=0,j,tabIndex=0;
1014 LPOLESTR *strgtable ;
1016 int len=lstrlenW(str);
1018 TRACE("%s, %p\n", debugstr_w(str), *stringTable);
1020 strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR));
1022 if (strgtable==NULL)
1023 return E_OUTOFMEMORY;
1025 while(str[i]!=0){
1027 if(str[i]==bSlash[0]){
1029 strgtable[tabIndex]=CoTaskMemAlloc(2*sizeof(WCHAR));
1031 if (strgtable[tabIndex]==NULL)
1032 return E_OUTOFMEMORY;
1034 strcpyW(strgtable[tabIndex++],bSlash);
1036 i++;
1039 else {
1041 for(j=0; str[i]!=0 && str[i]!=bSlash[0] ; i++,j++)
1042 word[j]=str[i];
1044 word[j]=0;
1046 strgtable[tabIndex]=CoTaskMemAlloc(sizeof(WCHAR)*(j+1));
1048 if (strgtable[tabIndex]==NULL)
1049 return E_OUTOFMEMORY;
1051 strcpyW(strgtable[tabIndex++],word);
1054 strgtable[tabIndex]=NULL;
1056 *stringTable=strgtable;
1058 return tabIndex;
1061 /******************************************************************************
1062 * FileMoniker_RelativePathTo
1064 static HRESULT WINAPI
1065 FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
1067 IBindCtx *bind;
1068 HRESULT res;
1069 LPOLESTR str1=0,str2=0,*tabStr1=0,*tabStr2=0,relPath=0;
1070 DWORD len1=0,len2=0,sameIdx=0,j=0;
1071 static const WCHAR back[] ={'.','.','\\',0};
1073 TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
1075 if (ppmkRelPath==NULL)
1076 return E_POINTER;
1078 if (pmOther==NULL)
1079 return E_INVALIDARG;
1081 res=CreateBindCtx(0,&bind);
1082 if (FAILED(res))
1083 return res;
1085 res=IMoniker_GetDisplayName(iface,bind,NULL,&str1);
1086 if (FAILED(res))
1087 return res;
1088 res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2);
1089 if (FAILED(res))
1090 return res;
1092 len1=FileMonikerImpl_DecomposePath(str1,&tabStr1);
1093 len2=FileMonikerImpl_DecomposePath(str2,&tabStr2);
1095 if (FAILED(len1) || FAILED(len2))
1096 return E_OUTOFMEMORY;
1098 /* count the number of similar items from the begin of the two paths */
1099 for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) &&
1100 (tabStr2[sameIdx]!=NULL) &&
1101 (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++);
1103 /* begin the construction of relativePath */
1104 /* if the two paths have a consecutive similar item from the begin ! the relativePath will be composed */
1105 /* by "..\\" in the begin */
1106 relPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(1+lstrlenW(str1)+lstrlenW(str2)));
1108 *relPath=0;
1110 if (len2>0 && !(len1==1 && len2==1 && sameIdx==0))
1111 for(j=sameIdx;(tabStr1[j] != NULL); j++)
1112 if (*tabStr1[j]!='\\')
1113 strcatW(relPath,back);
1115 /* add items of the second path (similar items with the first path are not included) to the relativePath */
1116 for(j=sameIdx;tabStr2[j]!=NULL;j++)
1117 strcatW(relPath,tabStr2[j]);
1119 res=CreateFileMoniker(relPath,ppmkRelPath);
1121 for(j=0; tabStr1[j]!=NULL;j++)
1122 CoTaskMemFree(tabStr1[j]);
1123 for(j=0; tabStr2[j]!=NULL;j++)
1124 CoTaskMemFree(tabStr2[j]);
1125 CoTaskMemFree(tabStr1);
1126 CoTaskMemFree(tabStr2);
1127 CoTaskMemFree(str1);
1128 CoTaskMemFree(str2);
1129 HeapFree(GetProcessHeap(),0,relPath);
1131 if (len1==0 || len2==0 || (len1==1 && len2==1 && sameIdx==0))
1132 return MK_S_HIM;
1134 return res;
1137 /******************************************************************************
1138 * FileMoniker_GetDisplayName
1140 static HRESULT WINAPI
1141 FileMonikerImpl_GetDisplayName(IMoniker* iface, IBindCtx* pbc,
1142 IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
1144 FileMonikerImpl *This = (FileMonikerImpl *)iface;
1146 int len=lstrlenW(This->filePathName);
1148 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
1150 if (ppszDisplayName==NULL)
1151 return E_POINTER;
1153 if (pmkToLeft!=NULL)
1154 return E_INVALIDARG;
1156 *ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR)*(len+1));
1157 if (*ppszDisplayName==NULL)
1158 return E_OUTOFMEMORY;
1160 strcpyW(*ppszDisplayName,This->filePathName);
1162 TRACE("-- %s\n", debugstr_w(*ppszDisplayName));
1164 return S_OK;
1167 /******************************************************************************
1168 * FileMoniker_ParseDisplayName
1170 static HRESULT WINAPI
1171 FileMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
1172 LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
1174 FIXME("(%p,%p,%p,%p,%p,%p),stub!\n",iface,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
1175 return E_NOTIMPL;
1178 /******************************************************************************
1179 * FileMoniker_IsSystemMoniker
1181 static HRESULT WINAPI
1182 FileMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
1184 TRACE("(%p,%p)\n",iface,pwdMksys);
1186 if (!pwdMksys)
1187 return E_POINTER;
1189 (*pwdMksys)=MKSYS_FILEMONIKER;
1191 return S_OK;
1194 /*******************************************************************************
1195 * FileMonikerIROTData_QueryInterface
1197 static HRESULT WINAPI
1198 FileMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
1201 ICOM_THIS_From_IROTData(IMoniker, iface);
1203 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
1205 return FileMonikerImpl_QueryInterface(This, riid, ppvObject);
1208 /***********************************************************************
1209 * FileMonikerIROTData_AddRef
1211 static ULONG WINAPI
1212 FileMonikerROTDataImpl_AddRef(IROTData *iface)
1214 ICOM_THIS_From_IROTData(IMoniker, iface);
1216 TRACE("(%p)\n",This);
1218 return IMoniker_AddRef(This);
1221 /***********************************************************************
1222 * FileMonikerIROTData_Release
1224 static ULONG WINAPI
1225 FileMonikerROTDataImpl_Release(IROTData* iface)
1227 ICOM_THIS_From_IROTData(IMoniker, iface);
1229 TRACE("(%p)\n",This);
1231 return FileMonikerImpl_Release(This);
1234 /******************************************************************************
1235 * FileMonikerIROTData_GetComparaisonData
1237 static HRESULT WINAPI
1238 FileMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
1239 ULONG cbMax, ULONG* pcbData)
1241 ICOM_THIS_From_IROTData(IMoniker, iface);
1242 FileMonikerImpl *This1 = (FileMonikerImpl *)This;
1243 int len = (strlenW(This1->filePathName)+1);
1244 int i;
1245 LPWSTR pszFileName;
1247 TRACE("(%p, %lu, %p)\n", pbData, cbMax, pcbData);
1249 *pcbData = sizeof(CLSID) + len * sizeof(WCHAR);
1250 if (cbMax < *pcbData)
1251 return E_OUTOFMEMORY;
1253 memcpy(pbData, &CLSID_FileMoniker, sizeof(CLSID));
1254 pszFileName = (LPWSTR)(pbData+sizeof(CLSID));
1255 for (i = 0; i < len; i++)
1256 pszFileName[i] = toupperW(This1->filePathName[i]);
1258 return S_OK;
1262 * Virtual function table for the FileMonikerImpl class which include IPersist,
1263 * IPersistStream and IMoniker functions.
1265 static const IMonikerVtbl VT_FileMonikerImpl =
1267 FileMonikerImpl_QueryInterface,
1268 FileMonikerImpl_AddRef,
1269 FileMonikerImpl_Release,
1270 FileMonikerImpl_GetClassID,
1271 FileMonikerImpl_IsDirty,
1272 FileMonikerImpl_Load,
1273 FileMonikerImpl_Save,
1274 FileMonikerImpl_GetSizeMax,
1275 FileMonikerImpl_BindToObject,
1276 FileMonikerImpl_BindToStorage,
1277 FileMonikerImpl_Reduce,
1278 FileMonikerImpl_ComposeWith,
1279 FileMonikerImpl_Enum,
1280 FileMonikerImpl_IsEqual,
1281 FileMonikerImpl_Hash,
1282 FileMonikerImpl_IsRunning,
1283 FileMonikerImpl_GetTimeOfLastChange,
1284 FileMonikerImpl_Inverse,
1285 FileMonikerImpl_CommonPrefixWith,
1286 FileMonikerImpl_RelativePathTo,
1287 FileMonikerImpl_GetDisplayName,
1288 FileMonikerImpl_ParseDisplayName,
1289 FileMonikerImpl_IsSystemMoniker
1292 /* Virtual function table for the IROTData class. */
1293 static const IROTDataVtbl VT_ROTDataImpl =
1295 FileMonikerROTDataImpl_QueryInterface,
1296 FileMonikerROTDataImpl_AddRef,
1297 FileMonikerROTDataImpl_Release,
1298 FileMonikerROTDataImpl_GetComparisonData
1301 /******************************************************************************
1302 * FileMoniker_Construct (local function)
1304 static HRESULT WINAPI
1305 FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPathName)
1307 int nb=0,i;
1308 int sizeStr=lstrlenW(lpszPathName);
1309 LPOLESTR *tabStr=0;
1310 static const WCHAR twoPoint[]={'.','.',0};
1311 static const WCHAR bkSlash[]={'\\',0};
1312 BYTE addBkSlash;
1314 TRACE("(%p,%s)\n",This,debugstr_w(lpszPathName));
1316 /* Initialize the virtual fgunction table. */
1317 This->lpvtbl1 = &VT_FileMonikerImpl;
1318 This->lpvtbl2 = &VT_ROTDataImpl;
1319 This->ref = 0;
1320 This->pMarshal = NULL;
1322 This->filePathName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr+1));
1324 if (This->filePathName==NULL)
1325 return E_OUTOFMEMORY;
1327 strcpyW(This->filePathName,lpszPathName);
1329 nb=FileMonikerImpl_DecomposePath(This->filePathName,&tabStr);
1331 if (nb > 0 ){
1333 addBkSlash=1;
1334 if (lstrcmpW(tabStr[0],twoPoint)!=0)
1335 addBkSlash=0;
1336 else
1337 for(i=0;i<nb;i++){
1339 if ( (lstrcmpW(tabStr[i],twoPoint)!=0) && (lstrcmpW(tabStr[i],bkSlash)!=0) ){
1340 addBkSlash=0;
1341 break;
1343 else
1345 if (lstrcmpW(tabStr[i],bkSlash)==0 && i<nb-1 && lstrcmpW(tabStr[i+1],bkSlash)==0){
1346 *tabStr[i]=0;
1347 sizeStr--;
1348 addBkSlash=0;
1349 break;
1353 if (lstrcmpW(tabStr[nb-1],bkSlash)==0)
1354 addBkSlash=0;
1356 This->filePathName=HeapReAlloc(GetProcessHeap(),0,This->filePathName,(sizeStr+1)*sizeof(WCHAR));
1358 *This->filePathName=0;
1360 for(i=0;tabStr[i]!=NULL;i++)
1361 strcatW(This->filePathName,tabStr[i]);
1363 if (addBkSlash)
1364 strcatW(This->filePathName,bkSlash);
1367 for(i=0; tabStr[i]!=NULL;i++)
1368 CoTaskMemFree(tabStr[i]);
1369 CoTaskMemFree(tabStr);
1371 return S_OK;
1374 /******************************************************************************
1375 * CreateFileMoniker (OLE32.@)
1376 ******************************************************************************/
1377 HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, LPMONIKER * ppmk)
1379 FileMonikerImpl* newFileMoniker;
1380 HRESULT hr;
1382 TRACE("(%s,%p)\n",debugstr_w(lpszPathName),ppmk);
1384 if (!ppmk)
1385 return E_POINTER;
1387 if(!lpszPathName)
1388 return MK_E_SYNTAX;
1390 *ppmk=NULL;
1392 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
1394 if (!newFileMoniker)
1395 return E_OUTOFMEMORY;
1397 hr = FileMonikerImpl_Construct(newFileMoniker,lpszPathName);
1399 if (SUCCEEDED(hr))
1400 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&IID_IMoniker,(void**)ppmk);
1401 else
1402 HeapFree(GetProcessHeap(),0,newFileMoniker);
1404 return hr;
1407 static HRESULT WINAPI FileMonikerCF_QueryInterface(LPCLASSFACTORY iface,
1408 REFIID riid, LPVOID *ppv)
1410 *ppv = NULL;
1411 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
1413 *ppv = iface;
1414 IUnknown_AddRef(iface);
1415 return S_OK;
1417 return E_NOINTERFACE;
1420 static ULONG WINAPI FileMonikerCF_AddRef(LPCLASSFACTORY iface)
1422 return 2; /* non-heap based object */
1425 static ULONG WINAPI FileMonikerCF_Release(LPCLASSFACTORY iface)
1427 return 1; /* non-heap based object */
1430 static HRESULT WINAPI FileMonikerCF_CreateInstance(LPCLASSFACTORY iface,
1431 LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
1433 FileMonikerImpl* newFileMoniker;
1434 HRESULT hr;
1435 static const WCHAR wszEmpty[] = { 0 };
1437 TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
1439 *ppv = NULL;
1441 if (pUnk)
1442 return CLASS_E_NOAGGREGATION;
1444 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
1445 if (!newFileMoniker)
1446 return E_OUTOFMEMORY;
1448 hr = FileMonikerImpl_Construct(newFileMoniker, wszEmpty);
1450 if (SUCCEEDED(hr))
1451 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker, riid, ppv);
1452 if (FAILED(hr))
1453 HeapFree(GetProcessHeap(),0,newFileMoniker);
1455 return hr;
1458 static HRESULT WINAPI FileMonikerCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
1460 FIXME("(%d), stub!\n",fLock);
1461 return S_OK;
1464 static const IClassFactoryVtbl FileMonikerCFVtbl =
1466 FileMonikerCF_QueryInterface,
1467 FileMonikerCF_AddRef,
1468 FileMonikerCF_Release,
1469 FileMonikerCF_CreateInstance,
1470 FileMonikerCF_LockServer
1472 static const IClassFactoryVtbl *FileMonikerCF = &FileMonikerCFVtbl;
1474 HRESULT FileMonikerCF_Create(REFIID riid, LPVOID *ppv)
1476 return IClassFactory_QueryInterface((IClassFactory *)&FileMonikerCF, riid, ppv);