shell32/tests: Hack SHGetFileInfo() so it does not crash and add a test for it.
[wine/hacks.git] / dlls / ole32 / filemoniker.c
blob562c92f0ad397cb49baf525cf3b14e49598ed373
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 /* filemoniker data structure */
43 typedef struct FileMonikerImpl{
45 const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
47 /* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
48 * two monikers are equal. That's whay IROTData interface is implemented by monikers.
50 const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
52 LONG ref; /* reference counter for this object */
54 LPOLESTR filePathName; /* path string identified by this filemoniker */
56 IUnknown *pMarshal; /* custom marshaler */
57 } FileMonikerImpl;
59 static inline IMoniker *impl_from_IROTData( IROTData *iface )
61 return (IMoniker *)((char*)iface - FIELD_OFFSET(FileMonikerImpl, lpvtbl2));
64 /* Local function used by filemoniker implementation */
65 static HRESULT WINAPI FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName);
66 static HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* iface);
68 /*******************************************************************************
69 * FileMoniker_QueryInterface
71 static HRESULT WINAPI
72 FileMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
74 FileMonikerImpl *This = (FileMonikerImpl *)iface;
76 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
78 /* Perform a sanity check on the parameters.*/
79 if ( (This==0) || (ppvObject==0) )
80 return E_INVALIDARG;
82 /* Initialize the return parameter */
83 *ppvObject = 0;
85 /* Compare the riid with the interface IDs implemented by this object.*/
86 if (IsEqualIID(&IID_IUnknown, riid) ||
87 IsEqualIID(&IID_IPersist, riid) ||
88 IsEqualIID(&IID_IPersistStream,riid) ||
89 IsEqualIID(&IID_IMoniker, riid)
91 *ppvObject = iface;
93 else if (IsEqualIID(&IID_IROTData, riid))
94 *ppvObject = (IROTData*)&(This->lpvtbl2);
95 else if (IsEqualIID(&IID_IMarshal, riid))
97 HRESULT hr = S_OK;
98 if (!This->pMarshal)
99 hr = MonikerMarshal_Create(iface, &This->pMarshal);
100 if (hr != S_OK)
101 return hr;
102 return IUnknown_QueryInterface(This->pMarshal, riid, ppvObject);
105 /* Check that we obtained an interface.*/
106 if ((*ppvObject)==0)
107 return E_NOINTERFACE;
109 /* Query Interface always increases the reference count by one when it is successful */
110 IMoniker_AddRef(iface);
112 return S_OK;
115 /******************************************************************************
116 * FileMoniker_AddRef
118 static ULONG WINAPI
119 FileMonikerImpl_AddRef(IMoniker* iface)
121 FileMonikerImpl *This = (FileMonikerImpl *)iface;
123 TRACE("(%p)\n",iface);
125 return InterlockedIncrement(&This->ref);
128 /******************************************************************************
129 * FileMoniker_Release
131 static ULONG WINAPI
132 FileMonikerImpl_Release(IMoniker* iface)
134 FileMonikerImpl *This = (FileMonikerImpl *)iface;
135 ULONG ref;
137 TRACE("(%p)\n",iface);
139 ref = InterlockedDecrement(&This->ref);
141 /* destroy the object if there's no more reference on it */
142 if (ref == 0) FileMonikerImpl_Destroy(This);
144 return ref;
147 /******************************************************************************
148 * FileMoniker_GetClassID
150 static HRESULT WINAPI
151 FileMonikerImpl_GetClassID(IMoniker* iface, CLSID *pClassID)
153 TRACE("(%p,%p)\n",iface,pClassID);
155 if (pClassID==NULL)
156 return E_POINTER;
158 *pClassID = CLSID_FileMoniker;
160 return S_OK;
163 /******************************************************************************
164 * FileMoniker_IsDirty
166 * Note that the OLE-provided implementations of the IPersistStream::IsDirty
167 * method in the OLE-provided moniker interfaces always return S_FALSE because
168 * their internal state never changes.
170 static HRESULT WINAPI
171 FileMonikerImpl_IsDirty(IMoniker* iface)
174 TRACE("(%p)\n",iface);
176 return S_FALSE;
179 /******************************************************************************
180 * FileMoniker_Load
182 * this function locates and reads from the stream the filePath string
183 * written by FileMonikerImpl_Save
185 static HRESULT WINAPI
186 FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
188 HRESULT res;
189 CHAR* filePathA = NULL;
190 WCHAR* filePathW = NULL;
191 ULONG bread;
192 WORD wbuffer;
193 DWORD dwbuffer, bytesA, bytesW, len;
194 int i;
196 FileMonikerImpl *This = (FileMonikerImpl *)iface;
198 TRACE("(%p,%p)\n",iface,pStm);
200 /* first WORD must be 0 */
201 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
202 if (bread!=sizeof(WORD) || wbuffer!=0)
204 WARN("Couldn't read 0 word\n");
205 goto fail;
208 /* read filePath string length (plus one) */
209 res=IStream_Read(pStm,&bytesA,sizeof(DWORD),&bread);
210 if (bread != sizeof(DWORD))
212 WARN("Couldn't read file string length\n");
213 goto fail;
216 /* read filePath string */
217 filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
218 if (!filePathA)
220 res = E_OUTOFMEMORY;
221 goto fail;
224 res=IStream_Read(pStm,filePathA,bytesA,&bread);
225 if (bread != bytesA)
227 WARN("Couldn't read file path string\n");
228 goto fail;
231 /* read the first constant */
232 IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
233 if (bread != sizeof(DWORD) || dwbuffer != 0xDEADFFFF)
235 WARN("Couldn't read 0xDEADFFFF constant\n");
236 goto fail;
239 for(i=0;i<5;i++)
241 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
242 if (bread!=sizeof(DWORD) || dwbuffer!=0)
244 WARN("Couldn't read 0 padding\n");
245 goto fail;
249 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
250 if (bread!=sizeof(DWORD))
251 goto fail;
253 if (!dwbuffer) /* No W-string */
255 bytesA--;
256 len=MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, bytesA, NULL, 0);
257 if (!len)
258 goto fail;
260 filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
261 if (!filePathW)
263 res = E_OUTOFMEMORY;
264 goto fail;
266 MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, -1, filePathW, len+1);
267 goto succeed;
270 if (dwbuffer < 6)
271 goto fail;
273 bytesW=dwbuffer - 6;
275 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
276 if (bread!=sizeof(DWORD) || dwbuffer!=bytesW)
277 goto fail;
279 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
280 if (bread!=sizeof(WORD) || wbuffer!=0x3)
281 goto fail;
283 len=bytesW/sizeof(WCHAR);
284 filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
285 if(!filePathW)
287 res = E_OUTOFMEMORY;
288 goto fail;
290 res=IStream_Read(pStm,filePathW,bytesW,&bread);
291 if (bread!=bytesW)
292 goto fail;
294 filePathW[len]=0;
296 succeed:
297 HeapFree(GetProcessHeap(),0,filePathA);
298 HeapFree(GetProcessHeap(),0,This->filePathName);
299 This->filePathName=filePathW;
301 return S_OK;
303 fail:
304 HeapFree(GetProcessHeap(), 0, filePathA);
305 HeapFree(GetProcessHeap(), 0, filePathW);
307 if (SUCCEEDED(res))
308 res = E_FAIL;
309 return res;
312 /******************************************************************************
313 * FileMoniker_Save
315 * This function saves data of this object. In the beginning I thought
316 * that I have just to write the filePath string on Stream. But, when I
317 * tested this function with windows programs samples, I noticed that it
318 * was not the case. This implementation is based on XP SP2. Other versions
319 * of Windows have minor variations.
321 * Data which must be written on stream is:
322 * 1) WORD constant:zero
323 * 2) length of the path string ("\0" included)
324 * 3) path string type A
325 * 4) DWORD constant : 0xDEADFFFF
326 * 5) five DWORD constant: zero
327 * 6) If we're only writing the multibyte version,
328 * write a zero DWORD and finish.
330 * 7) DWORD: double-length of the the path string type W ("\0" not
331 * included)
332 * 8) WORD constant: 0x3
333 * 9) filePath unicode string.
336 static HRESULT WINAPI
337 FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
339 FileMonikerImpl *This = (FileMonikerImpl *)iface;
341 HRESULT res;
342 LPOLESTR filePathW=This->filePathName;
343 CHAR* filePathA;
344 DWORD bytesA, bytesW, len;
346 static const DWORD DEADFFFF = 0xDEADFFFF; /* Constants */
347 static const DWORD ZERO = 0;
348 static const WORD THREE = 0x3;
350 int i;
351 BOOL bUsedDefault, bWriteWide;
353 TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
355 if (pStm==NULL)
356 return E_POINTER;
358 /* write a 0 WORD */
359 res=IStream_Write(pStm,&ZERO,sizeof(WORD),NULL);
360 if (!SUCCEEDED(res)) return res;
362 /* write length of filePath string ( 0 included )*/
363 bytesA = WideCharToMultiByte( CP_ACP, 0, filePathW, -1, NULL, 0, NULL, NULL );
364 res=IStream_Write(pStm,&bytesA,sizeof(DWORD),NULL);
365 if (!SUCCEEDED(res)) return res;
367 /* write A string (with '\0') */
368 filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
369 if (!filePathA)
370 return E_OUTOFMEMORY;
371 WideCharToMultiByte( CP_ACP, 0, filePathW, -1, filePathA, bytesA, NULL, &bUsedDefault);
372 res=IStream_Write(pStm,filePathA,bytesA,NULL);
373 HeapFree(GetProcessHeap(),0,filePathA);
374 if (!SUCCEEDED(res)) return res;
376 /* write a DWORD 0xDEADFFFF */
377 res=IStream_Write(pStm,&DEADFFFF,sizeof(DWORD),NULL);
378 if (!SUCCEEDED(res)) return res;
380 /* write 5 zero DWORDs */
381 for(i=0;i<5;i++)
383 res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
384 if (!SUCCEEDED(res)) return res;
387 /* Write the wide version if:
388 * + couldn't convert to CP_ACP,
389 * or + it's a directory,
390 * or + there's a character > 0xFF
392 len = lstrlenW(filePathW);
393 bWriteWide = (bUsedDefault || (len > 0 && filePathW[len-1]=='\\' ));
394 if (!bWriteWide)
396 WCHAR* pch;
397 for(pch=filePathW;*pch;++pch)
399 if (*pch > 0xFF)
401 bWriteWide = TRUE;
402 break;
407 if (!bWriteWide)
409 res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
410 return res;
413 /* write bytes needed for the filepathW (without 0) + 6 */
414 bytesW = len*sizeof(WCHAR) + 6;
415 res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
416 if (!SUCCEEDED(res)) return res;
418 /* try again, without the extra 6 */
419 bytesW -= 6;
420 res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
421 if (!SUCCEEDED(res)) return res;
423 /* write a WORD 3 */
424 res=IStream_Write(pStm,&THREE,sizeof(WORD),NULL);
425 if (!SUCCEEDED(res)) return res;
427 /* write W string (no 0) */
428 res=IStream_Write(pStm,filePathW,bytesW,NULL);
430 return res;
433 /******************************************************************************
434 * FileMoniker_GetSizeMax
436 static HRESULT WINAPI
437 FileMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
439 FileMonikerImpl *This = (FileMonikerImpl *)iface;
441 TRACE("(%p,%p)\n",iface,pcbSize);
443 if (!pcbSize)
444 return E_POINTER;
446 /* We could calculate exactly (see ...::Save()) but instead
447 * we'll make a quick over-estimate, like Windows (NT4, XP) does.
449 pcbSize->u.LowPart = 0x38 + 4 * lstrlenW(This->filePathName);
450 pcbSize->u.HighPart = 0;
452 return S_OK;
455 /******************************************************************************
456 * FileMoniker_Destroy (local function)
457 *******************************************************************************/
458 HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* This)
460 TRACE("(%p)\n",This);
462 if (This->pMarshal) IUnknown_Release(This->pMarshal);
463 HeapFree(GetProcessHeap(),0,This->filePathName);
464 HeapFree(GetProcessHeap(),0,This);
466 return S_OK;
469 /******************************************************************************
470 * FileMoniker_BindToObject
472 static HRESULT WINAPI
473 FileMonikerImpl_BindToObject(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
474 REFIID riid, VOID** ppvResult)
476 HRESULT res=E_FAIL;
477 CLSID clsID;
478 IUnknown* pObj=0;
479 IRunningObjectTable *prot=0;
480 IPersistFile *ppf=0;
481 IClassFactory *pcf=0;
482 IClassActivator *pca=0;
484 FileMonikerImpl *This = (FileMonikerImpl *)iface;
486 *ppvResult=0;
488 TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
490 if(pmkToLeft==NULL){
492 res=IBindCtx_GetRunningObjectTable(pbc,&prot);
494 if (SUCCEEDED(res)){
495 /* if the requested class was loaded before ! we don't need to reload it */
496 res = IRunningObjectTable_GetObject(prot,iface,&pObj);
498 if (res==S_FALSE){
499 /* first activation of this class */
500 res=GetClassFile(This->filePathName,&clsID);
501 if (SUCCEEDED(res)){
503 res=CoCreateInstance(&clsID,NULL,CLSCTX_ALL,&IID_IPersistFile,(void**)&ppf);
504 if (SUCCEEDED(res)){
506 res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
507 if (SUCCEEDED(res)){
509 pObj=(IUnknown*)ppf;
510 IUnknown_AddRef(pObj);
517 else{
518 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassFactory,(void**)&pcf);
520 if (res==E_NOINTERFACE){
522 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca);
524 if (res==E_NOINTERFACE)
525 return MK_E_INTERMEDIATEINTERFACENOTSUPPORTED;
527 if (pcf!=NULL){
529 IClassFactory_CreateInstance(pcf,NULL,&IID_IPersistFile,(void**)&ppf);
531 res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
533 if (SUCCEEDED(res)){
535 pObj=(IUnknown*)ppf;
536 IUnknown_AddRef(pObj);
539 if (pca!=NULL){
541 FIXME("()\n");
543 /*res=GetClassFile(This->filePathName,&clsID);
545 if (SUCCEEDED(res)){
547 res=IClassActivator_GetClassObject(pca,&clsID,CLSCTX_ALL,0,&IID_IPersistFile,(void**)&ppf);
549 if (SUCCEEDED(res)){
551 pObj=(IUnknown*)ppf;
552 IUnknown_AddRef(pObj);
558 if (pObj!=NULL){
559 /* get the requested interface from the loaded class */
560 res= IUnknown_QueryInterface(pObj,riid,ppvResult);
562 IBindCtx_RegisterObjectBound(pbc,(IUnknown*)*ppvResult);
564 IUnknown_Release(pObj);
567 if (prot!=NULL)
568 IRunningObjectTable_Release(prot);
570 if (ppf!=NULL)
571 IPersistFile_Release(ppf);
573 if (pca!=NULL)
574 IClassActivator_Release(pca);
576 if (pcf!=NULL)
577 IClassFactory_Release(pcf);
579 return res;
582 /******************************************************************************
583 * FileMoniker_BindToStorage
585 static HRESULT WINAPI
586 FileMonikerImpl_BindToStorage(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
587 REFIID riid, VOID** ppvObject)
589 LPOLESTR filePath=0;
590 IStorage *pstg=0;
591 HRESULT res;
593 TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvObject);
595 if (pmkToLeft==NULL){
597 if (IsEqualIID(&IID_IStorage, riid)){
599 /* get the file name */
600 IMoniker_GetDisplayName(iface,pbc,pmkToLeft,&filePath);
602 /* verifie if the file contains a storage object */
603 res=StgIsStorageFile(filePath);
605 if(res==S_OK){
607 res=StgOpenStorage(filePath,NULL,STGM_READWRITE|STGM_SHARE_DENY_WRITE,NULL,0,&pstg);
609 if (SUCCEEDED(res)){
611 *ppvObject=pstg;
613 IStorage_AddRef(pstg);
615 return res;
618 CoTaskMemFree(filePath);
620 else
621 if ( (IsEqualIID(&IID_IStream, riid)) || (IsEqualIID(&IID_ILockBytes, riid)) )
622 return E_FAIL;
623 else
624 return E_NOINTERFACE;
626 else {
628 FIXME("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvObject);
630 return E_NOTIMPL;
632 return res;
635 /******************************************************************************
636 * FileMoniker_Reduce
637 ******************************************************************************/
638 static HRESULT WINAPI
639 FileMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar,
640 IMoniker** ppmkToLeft, IMoniker** ppmkReduced)
642 TRACE("(%p,%p,%d,%p,%p)\n",iface,pbc,dwReduceHowFar,ppmkToLeft,ppmkReduced);
644 if (ppmkReduced==NULL)
645 return E_POINTER;
647 IMoniker_AddRef(iface);
649 *ppmkReduced=iface;
651 return MK_S_REDUCED_TO_SELF;
654 /******************************************************************************
655 * FileMoniker_ComposeWith
657 static HRESULT WINAPI
658 FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
659 BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite)
661 HRESULT res;
662 LPOLESTR str1=0,str2=0,*strDec1=0,*strDec2=0,newStr=0;
663 static const WCHAR twoPoint[]={'.','.',0};
664 static const WCHAR bkSlash[]={'\\',0};
665 IBindCtx *bind=0;
666 int i=0,j=0,lastIdx1=0,lastIdx2=0;
667 DWORD mkSys;
669 TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
671 if (ppmkComposite==NULL)
672 return E_POINTER;
674 if (pmkRight==NULL)
675 return E_INVALIDARG;
677 *ppmkComposite=0;
679 IMoniker_IsSystemMoniker(pmkRight,&mkSys);
681 /* check if we have two filemonikers to compose or not */
682 if(mkSys==MKSYS_FILEMONIKER){
684 CreateBindCtx(0,&bind);
686 IMoniker_GetDisplayName(iface,bind,NULL,&str1);
687 IMoniker_GetDisplayName(pmkRight,bind,NULL,&str2);
689 /* decompose pathnames of the two monikers : (to prepare the path merge operation ) */
690 lastIdx1=FileMonikerImpl_DecomposePath(str1,&strDec1)-1;
691 lastIdx2=FileMonikerImpl_DecomposePath(str2,&strDec2)-1;
693 if ((lastIdx1==-1 && lastIdx2>-1)||(lastIdx1==1 && lstrcmpW(strDec1[0],twoPoint)==0))
694 return MK_E_SYNTAX;
696 if(lstrcmpW(strDec1[lastIdx1],bkSlash)==0)
697 lastIdx1--;
699 /* for etch "..\" in the left of str2 remove the right element from str1 */
700 for(i=0; ( (lastIdx1>=0) && (strDec2[i]!=NULL) && (lstrcmpW(strDec2[i],twoPoint)==0) ) ;i+=2){
702 lastIdx1-=2;
705 /* the length of the composed path string is raised by the sum of the two paths lengths */
706 newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
708 if (newStr==NULL)
709 return E_OUTOFMEMORY;
711 /* new path is the concatenation of the rest of str1 and str2 */
712 for(*newStr=0,j=0;j<=lastIdx1;j++)
713 strcatW(newStr,strDec1[j]);
715 if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || lstrcmpW(strDec2[i],bkSlash)!=0)
716 strcatW(newStr,bkSlash);
718 for(j=i;j<=lastIdx2;j++)
719 strcatW(newStr,strDec2[j]);
721 /* create a new moniker with the new string */
722 res=CreateFileMoniker(newStr,ppmkComposite);
724 /* free all strings space memory used by this function */
725 HeapFree(GetProcessHeap(),0,newStr);
727 for(i=0; strDec1[i]!=NULL;i++)
728 CoTaskMemFree(strDec1[i]);
729 for(i=0; strDec2[i]!=NULL;i++)
730 CoTaskMemFree(strDec2[i]);
731 CoTaskMemFree(strDec1);
732 CoTaskMemFree(strDec2);
734 CoTaskMemFree(str1);
735 CoTaskMemFree(str2);
737 return res;
739 else if(mkSys==MKSYS_ANTIMONIKER){
741 *ppmkComposite=NULL;
742 return S_OK;
744 else if (fOnlyIfNotGeneric){
746 *ppmkComposite=NULL;
747 return MK_E_NEEDGENERIC;
749 else
751 return CreateGenericComposite(iface,pmkRight,ppmkComposite);
754 /******************************************************************************
755 * FileMoniker_Enum
757 static HRESULT WINAPI
758 FileMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
760 TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker);
762 if (ppenumMoniker == NULL)
763 return E_POINTER;
765 *ppenumMoniker = NULL;
767 return S_OK;
770 /******************************************************************************
771 * FileMoniker_IsEqual
773 static HRESULT WINAPI
774 FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
776 FileMonikerImpl *This = (FileMonikerImpl *)iface;
777 CLSID clsid;
778 LPOLESTR filePath;
779 IBindCtx* bind;
780 HRESULT res;
782 TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
784 if (pmkOtherMoniker==NULL)
785 return S_FALSE;
787 IMoniker_GetClassID(pmkOtherMoniker,&clsid);
789 if (!IsEqualCLSID(&clsid,&CLSID_FileMoniker))
790 return S_FALSE;
792 res = CreateBindCtx(0,&bind);
793 if (FAILED(res)) return res;
795 if (SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath))) {
796 int result = lstrcmpiW(filePath, This->filePathName);
797 CoTaskMemFree(filePath);
798 if ( result == 0 ) return S_OK;
800 return S_FALSE;
804 /******************************************************************************
805 * FileMoniker_Hash
807 static HRESULT WINAPI
808 FileMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
810 FileMonikerImpl *This = (FileMonikerImpl *)iface;
812 int h = 0,i,skip,len;
813 int off = 0;
814 LPOLESTR val;
816 if (pdwHash==NULL)
817 return E_POINTER;
819 val = This->filePathName;
820 len = lstrlenW(val);
822 if (len < 16) {
823 for (i = len ; i > 0; i--) {
824 h = (h * 37) + val[off++];
826 } else {
827 /* only sample some characters */
828 skip = len / 8;
829 for (i = len ; i > 0; i -= skip, off += skip) {
830 h = (h * 39) + val[off];
834 *pdwHash=h;
836 return S_OK;
839 /******************************************************************************
840 * FileMoniker_IsRunning
842 static HRESULT WINAPI
843 FileMonikerImpl_IsRunning(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
844 IMoniker* pmkNewlyRunning)
846 IRunningObjectTable* rot;
847 HRESULT res;
849 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
851 if ( (pmkNewlyRunning!=NULL) && (IMoniker_IsEqual(pmkNewlyRunning,iface)==S_OK) )
852 return S_OK;
854 if (pbc==NULL)
855 return E_POINTER;
857 res=IBindCtx_GetRunningObjectTable(pbc,&rot);
859 if (FAILED(res))
860 return res;
862 res = IRunningObjectTable_IsRunning(rot,iface);
864 IRunningObjectTable_Release(rot);
866 return res;
869 /******************************************************************************
870 * FileMoniker_GetTimeOfLastChange
871 ******************************************************************************/
872 static HRESULT WINAPI
873 FileMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc,
874 IMoniker* pmkToLeft, FILETIME* pFileTime)
876 FileMonikerImpl *This = (FileMonikerImpl *)iface;
877 IRunningObjectTable* rot;
878 HRESULT res;
879 WIN32_FILE_ATTRIBUTE_DATA info;
881 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pFileTime);
883 if (pFileTime==NULL)
884 return E_POINTER;
886 if (pmkToLeft!=NULL)
887 return E_INVALIDARG;
889 res=IBindCtx_GetRunningObjectTable(pbc,&rot);
891 if (FAILED(res))
892 return res;
894 res= IRunningObjectTable_GetTimeOfLastChange(rot,iface,pFileTime);
896 if (FAILED(res)){ /* the moniker is not registered */
898 if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info))
899 return MK_E_NOOBJECT;
901 *pFileTime=info.ftLastWriteTime;
904 return S_OK;
907 /******************************************************************************
908 * FileMoniker_Inverse
910 static HRESULT WINAPI
911 FileMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
913 TRACE("(%p,%p)\n",iface,ppmk);
915 return CreateAntiMoniker(ppmk);
918 /******************************************************************************
919 * FileMoniker_CommonPrefixWith
921 static HRESULT WINAPI
922 FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
925 LPOLESTR pathThis,pathOther,*stringTable1,*stringTable2,commonPath;
926 IBindCtx *pbind;
927 DWORD mkSys;
928 ULONG nb1,nb2,i,sameIdx;
929 BOOL machimeNameCase=FALSE;
931 if (ppmkPrefix==NULL)
932 return E_POINTER;
934 if (pmkOther==NULL)
935 return E_INVALIDARG;
937 *ppmkPrefix=0;
939 /* check if we have the same type of moniker */
940 IMoniker_IsSystemMoniker(pmkOther,&mkSys);
942 if(mkSys==MKSYS_FILEMONIKER){
943 HRESULT ret;
945 CreateBindCtx(0,&pbind);
947 /* create a string based on common part of the two paths */
949 IMoniker_GetDisplayName(iface,pbind,NULL,&pathThis);
950 IMoniker_GetDisplayName(pmkOther,pbind,NULL,&pathOther);
952 nb1=FileMonikerImpl_DecomposePath(pathThis,&stringTable1);
953 nb2=FileMonikerImpl_DecomposePath(pathOther,&stringTable2);
955 if (nb1==0 || nb2==0)
956 return MK_E_NOPREFIX;
958 commonPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(min(lstrlenW(pathThis),lstrlenW(pathOther))+1));
960 *commonPath=0;
962 for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) &&
963 (stringTable2[sameIdx]!=NULL) &&
964 (lstrcmpiW(stringTable1[sameIdx],stringTable2[sameIdx])==0)); sameIdx++);
966 if (sameIdx > 1 && *stringTable1[0]=='\\' && *stringTable2[1]=='\\'){
968 machimeNameCase=TRUE;
970 for(i=2;i<sameIdx;i++)
972 if( (*stringTable1[i]=='\\') && (i+1 < sameIdx) && (*stringTable1[i+1]=='\\') ){
973 machimeNameCase=FALSE;
974 break;
978 if (machimeNameCase && *stringTable1[sameIdx-1]=='\\')
979 sameIdx--;
981 if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) )
982 ret = MK_E_NOPREFIX;
983 else
985 for(i=0;i<sameIdx;i++)
986 strcatW(commonPath,stringTable1[i]);
988 for(i=0;i<nb1;i++)
989 CoTaskMemFree(stringTable1[i]);
991 CoTaskMemFree(stringTable1);
993 for(i=0;i<nb2;i++)
994 CoTaskMemFree(stringTable2[i]);
996 CoTaskMemFree(stringTable2);
998 ret = CreateFileMoniker(commonPath,ppmkPrefix);
1000 HeapFree(GetProcessHeap(),0,commonPath);
1001 return ret;
1003 else
1004 return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
1007 /******************************************************************************
1008 * DecomposePath (local function)
1010 int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
1012 static const WCHAR bSlash[] = {'\\',0};
1013 WCHAR word[MAX_PATH];
1014 int i=0,j,tabIndex=0;
1015 LPOLESTR *strgtable ;
1017 int len=lstrlenW(str);
1019 TRACE("%s, %p\n", debugstr_w(str), *stringTable);
1021 strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR));
1023 if (strgtable==NULL)
1024 return E_OUTOFMEMORY;
1026 while(str[i]!=0){
1028 if(str[i]==bSlash[0]){
1030 strgtable[tabIndex]=CoTaskMemAlloc(2*sizeof(WCHAR));
1032 if (strgtable[tabIndex]==NULL)
1033 return E_OUTOFMEMORY;
1035 strcpyW(strgtable[tabIndex++],bSlash);
1037 i++;
1040 else {
1042 for(j=0; str[i]!=0 && str[i]!=bSlash[0] ; i++,j++)
1043 word[j]=str[i];
1045 word[j]=0;
1047 strgtable[tabIndex]=CoTaskMemAlloc(sizeof(WCHAR)*(j+1));
1049 if (strgtable[tabIndex]==NULL)
1050 return E_OUTOFMEMORY;
1052 strcpyW(strgtable[tabIndex++],word);
1055 strgtable[tabIndex]=NULL;
1057 *stringTable=strgtable;
1059 return tabIndex;
1062 /******************************************************************************
1063 * FileMoniker_RelativePathTo
1065 static HRESULT WINAPI
1066 FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
1068 IBindCtx *bind;
1069 HRESULT res;
1070 LPOLESTR str1=0,str2=0,*tabStr1=0,*tabStr2=0,relPath=0;
1071 DWORD len1=0,len2=0,sameIdx=0,j=0;
1072 static const WCHAR back[] ={'.','.','\\',0};
1074 TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
1076 if (ppmkRelPath==NULL)
1077 return E_POINTER;
1079 if (pmOther==NULL)
1080 return E_INVALIDARG;
1082 res=CreateBindCtx(0,&bind);
1083 if (FAILED(res))
1084 return res;
1086 res=IMoniker_GetDisplayName(iface,bind,NULL,&str1);
1087 if (FAILED(res))
1088 return res;
1089 res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2);
1090 if (FAILED(res))
1091 return res;
1093 len1=FileMonikerImpl_DecomposePath(str1,&tabStr1);
1094 len2=FileMonikerImpl_DecomposePath(str2,&tabStr2);
1096 if (FAILED(len1) || FAILED(len2))
1097 return E_OUTOFMEMORY;
1099 /* count the number of similar items from the begin of the two paths */
1100 for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) &&
1101 (tabStr2[sameIdx]!=NULL) &&
1102 (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++);
1104 /* begin the construction of relativePath */
1105 /* if the two paths have a consecutive similar item from the begin ! the relativePath will be composed */
1106 /* by "..\\" in the begin */
1107 relPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(1+lstrlenW(str1)+lstrlenW(str2)));
1109 *relPath=0;
1111 if (len2>0 && !(len1==1 && len2==1 && sameIdx==0))
1112 for(j=sameIdx;(tabStr1[j] != NULL); j++)
1113 if (*tabStr1[j]!='\\')
1114 strcatW(relPath,back);
1116 /* add items of the second path (similar items with the first path are not included) to the relativePath */
1117 for(j=sameIdx;tabStr2[j]!=NULL;j++)
1118 strcatW(relPath,tabStr2[j]);
1120 res=CreateFileMoniker(relPath,ppmkRelPath);
1122 for(j=0; tabStr1[j]!=NULL;j++)
1123 CoTaskMemFree(tabStr1[j]);
1124 for(j=0; tabStr2[j]!=NULL;j++)
1125 CoTaskMemFree(tabStr2[j]);
1126 CoTaskMemFree(tabStr1);
1127 CoTaskMemFree(tabStr2);
1128 CoTaskMemFree(str1);
1129 CoTaskMemFree(str2);
1130 HeapFree(GetProcessHeap(),0,relPath);
1132 if (len1==0 || len2==0 || (len1==1 && len2==1 && sameIdx==0))
1133 return MK_S_HIM;
1135 return res;
1138 /******************************************************************************
1139 * FileMoniker_GetDisplayName
1141 static HRESULT WINAPI
1142 FileMonikerImpl_GetDisplayName(IMoniker* iface, IBindCtx* pbc,
1143 IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
1145 FileMonikerImpl *This = (FileMonikerImpl *)iface;
1147 int len=lstrlenW(This->filePathName);
1149 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
1151 if (ppszDisplayName==NULL)
1152 return E_POINTER;
1154 if (pmkToLeft!=NULL)
1155 return E_INVALIDARG;
1157 *ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR)*(len+1));
1158 if (*ppszDisplayName==NULL)
1159 return E_OUTOFMEMORY;
1161 strcpyW(*ppszDisplayName,This->filePathName);
1163 TRACE("-- %s\n", debugstr_w(*ppszDisplayName));
1165 return S_OK;
1168 /******************************************************************************
1169 * FileMoniker_ParseDisplayName
1171 static HRESULT WINAPI
1172 FileMonikerImpl_ParseDisplayName(IMoniker* iface, IBindCtx* pbc, IMoniker* pmkToLeft,
1173 LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
1175 FIXME("(%p,%p,%p,%p,%p,%p),stub!\n",iface,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
1176 return E_NOTIMPL;
1179 /******************************************************************************
1180 * FileMoniker_IsSystemMoniker
1182 static HRESULT WINAPI
1183 FileMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
1185 TRACE("(%p,%p)\n",iface,pwdMksys);
1187 if (!pwdMksys)
1188 return E_POINTER;
1190 (*pwdMksys)=MKSYS_FILEMONIKER;
1192 return S_OK;
1195 /*******************************************************************************
1196 * FileMonikerIROTData_QueryInterface
1198 static HRESULT WINAPI
1199 FileMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
1202 IMoniker *This = impl_from_IROTData(iface);
1204 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
1206 return FileMonikerImpl_QueryInterface(This, riid, ppvObject);
1209 /***********************************************************************
1210 * FileMonikerIROTData_AddRef
1212 static ULONG WINAPI
1213 FileMonikerROTDataImpl_AddRef(IROTData *iface)
1215 IMoniker *This = impl_from_IROTData(iface);
1217 TRACE("(%p)\n",This);
1219 return IMoniker_AddRef(This);
1222 /***********************************************************************
1223 * FileMonikerIROTData_Release
1225 static ULONG WINAPI
1226 FileMonikerROTDataImpl_Release(IROTData* iface)
1228 IMoniker *This = impl_from_IROTData(iface);
1230 TRACE("(%p)\n",This);
1232 return FileMonikerImpl_Release(This);
1235 /******************************************************************************
1236 * FileMonikerIROTData_GetComparaisonData
1238 static HRESULT WINAPI
1239 FileMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
1240 ULONG cbMax, ULONG* pcbData)
1242 IMoniker *This = impl_from_IROTData(iface);
1243 FileMonikerImpl *This1 = (FileMonikerImpl *)This;
1244 int len = (strlenW(This1->filePathName)+1);
1245 int i;
1246 LPWSTR pszFileName;
1248 TRACE("(%p, %u, %p)\n", pbData, cbMax, pcbData);
1250 *pcbData = sizeof(CLSID) + len * sizeof(WCHAR);
1251 if (cbMax < *pcbData)
1252 return E_OUTOFMEMORY;
1254 memcpy(pbData, &CLSID_FileMoniker, sizeof(CLSID));
1255 pszFileName = (LPWSTR)(pbData+sizeof(CLSID));
1256 for (i = 0; i < len; i++)
1257 pszFileName[i] = toupperW(This1->filePathName[i]);
1259 return S_OK;
1263 * Virtual function table for the FileMonikerImpl class which include IPersist,
1264 * IPersistStream and IMoniker functions.
1266 static const IMonikerVtbl VT_FileMonikerImpl =
1268 FileMonikerImpl_QueryInterface,
1269 FileMonikerImpl_AddRef,
1270 FileMonikerImpl_Release,
1271 FileMonikerImpl_GetClassID,
1272 FileMonikerImpl_IsDirty,
1273 FileMonikerImpl_Load,
1274 FileMonikerImpl_Save,
1275 FileMonikerImpl_GetSizeMax,
1276 FileMonikerImpl_BindToObject,
1277 FileMonikerImpl_BindToStorage,
1278 FileMonikerImpl_Reduce,
1279 FileMonikerImpl_ComposeWith,
1280 FileMonikerImpl_Enum,
1281 FileMonikerImpl_IsEqual,
1282 FileMonikerImpl_Hash,
1283 FileMonikerImpl_IsRunning,
1284 FileMonikerImpl_GetTimeOfLastChange,
1285 FileMonikerImpl_Inverse,
1286 FileMonikerImpl_CommonPrefixWith,
1287 FileMonikerImpl_RelativePathTo,
1288 FileMonikerImpl_GetDisplayName,
1289 FileMonikerImpl_ParseDisplayName,
1290 FileMonikerImpl_IsSystemMoniker
1293 /* Virtual function table for the IROTData class. */
1294 static const IROTDataVtbl VT_ROTDataImpl =
1296 FileMonikerROTDataImpl_QueryInterface,
1297 FileMonikerROTDataImpl_AddRef,
1298 FileMonikerROTDataImpl_Release,
1299 FileMonikerROTDataImpl_GetComparisonData
1302 /******************************************************************************
1303 * FileMoniker_Construct (local function)
1305 static HRESULT WINAPI
1306 FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPathName)
1308 int nb=0,i;
1309 int sizeStr=lstrlenW(lpszPathName);
1310 LPOLESTR *tabStr=0;
1311 static const WCHAR twoPoint[]={'.','.',0};
1312 static const WCHAR bkSlash[]={'\\',0};
1313 BYTE addBkSlash;
1315 TRACE("(%p,%s)\n",This,debugstr_w(lpszPathName));
1317 /* Initialize the virtual fgunction table. */
1318 This->lpvtbl1 = &VT_FileMonikerImpl;
1319 This->lpvtbl2 = &VT_ROTDataImpl;
1320 This->ref = 0;
1321 This->pMarshal = NULL;
1323 This->filePathName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr+1));
1325 if (This->filePathName==NULL)
1326 return E_OUTOFMEMORY;
1328 strcpyW(This->filePathName,lpszPathName);
1330 nb=FileMonikerImpl_DecomposePath(This->filePathName,&tabStr);
1332 if (nb > 0 ){
1334 addBkSlash=1;
1335 if (lstrcmpW(tabStr[0],twoPoint)!=0)
1336 addBkSlash=0;
1337 else
1338 for(i=0;i<nb;i++){
1340 if ( (lstrcmpW(tabStr[i],twoPoint)!=0) && (lstrcmpW(tabStr[i],bkSlash)!=0) ){
1341 addBkSlash=0;
1342 break;
1344 else
1346 if (lstrcmpW(tabStr[i],bkSlash)==0 && i<nb-1 && lstrcmpW(tabStr[i+1],bkSlash)==0){
1347 *tabStr[i]=0;
1348 sizeStr--;
1349 addBkSlash=0;
1350 break;
1354 if (lstrcmpW(tabStr[nb-1],bkSlash)==0)
1355 addBkSlash=0;
1357 This->filePathName=HeapReAlloc(GetProcessHeap(),0,This->filePathName,(sizeStr+1)*sizeof(WCHAR));
1359 *This->filePathName=0;
1361 for(i=0;tabStr[i]!=NULL;i++)
1362 strcatW(This->filePathName,tabStr[i]);
1364 if (addBkSlash)
1365 strcatW(This->filePathName,bkSlash);
1368 for(i=0; tabStr[i]!=NULL;i++)
1369 CoTaskMemFree(tabStr[i]);
1370 CoTaskMemFree(tabStr);
1372 return S_OK;
1375 /******************************************************************************
1376 * CreateFileMoniker (OLE32.@)
1377 ******************************************************************************/
1378 HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, LPMONIKER * ppmk)
1380 FileMonikerImpl* newFileMoniker;
1381 HRESULT hr;
1383 TRACE("(%s,%p)\n",debugstr_w(lpszPathName),ppmk);
1385 if (!ppmk)
1386 return E_POINTER;
1388 if(!lpszPathName)
1389 return MK_E_SYNTAX;
1391 *ppmk=NULL;
1393 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
1395 if (!newFileMoniker)
1396 return E_OUTOFMEMORY;
1398 hr = FileMonikerImpl_Construct(newFileMoniker,lpszPathName);
1400 if (SUCCEEDED(hr))
1401 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker,&IID_IMoniker,(void**)ppmk);
1402 else
1403 HeapFree(GetProcessHeap(),0,newFileMoniker);
1405 return hr;
1408 static HRESULT WINAPI FileMonikerCF_QueryInterface(LPCLASSFACTORY iface,
1409 REFIID riid, LPVOID *ppv)
1411 *ppv = NULL;
1412 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory))
1414 *ppv = iface;
1415 IUnknown_AddRef(iface);
1416 return S_OK;
1418 return E_NOINTERFACE;
1421 static ULONG WINAPI FileMonikerCF_AddRef(LPCLASSFACTORY iface)
1423 return 2; /* non-heap based object */
1426 static ULONG WINAPI FileMonikerCF_Release(LPCLASSFACTORY iface)
1428 return 1; /* non-heap based object */
1431 static HRESULT WINAPI FileMonikerCF_CreateInstance(LPCLASSFACTORY iface,
1432 LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv)
1434 FileMonikerImpl* newFileMoniker;
1435 HRESULT hr;
1436 static const WCHAR wszEmpty[] = { 0 };
1438 TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
1440 *ppv = NULL;
1442 if (pUnk)
1443 return CLASS_E_NOAGGREGATION;
1445 newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
1446 if (!newFileMoniker)
1447 return E_OUTOFMEMORY;
1449 hr = FileMonikerImpl_Construct(newFileMoniker, wszEmpty);
1451 if (SUCCEEDED(hr))
1452 hr = FileMonikerImpl_QueryInterface((IMoniker*)newFileMoniker, riid, ppv);
1453 if (FAILED(hr))
1454 HeapFree(GetProcessHeap(),0,newFileMoniker);
1456 return hr;
1459 static HRESULT WINAPI FileMonikerCF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
1461 FIXME("(%d), stub!\n",fLock);
1462 return S_OK;
1465 static const IClassFactoryVtbl FileMonikerCFVtbl =
1467 FileMonikerCF_QueryInterface,
1468 FileMonikerCF_AddRef,
1469 FileMonikerCF_Release,
1470 FileMonikerCF_CreateInstance,
1471 FileMonikerCF_LockServer
1473 static const IClassFactoryVtbl *FileMonikerCF = &FileMonikerCFVtbl;
1475 HRESULT FileMonikerCF_Create(REFIID riid, LPVOID *ppv)
1477 return IClassFactory_QueryInterface((IClassFactory *)&FileMonikerCF, riid, ppv);