4 * Copyright 1999, 2000 Marcus Meissner
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
40 #include "oleaut32_oaidl.h"
42 #include "wine/debug.h"
43 #include "wine/unicode.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
46 WINE_DECLARE_DEBUG_CHANNEL(heap
);
48 /******************************************************************************
52 * BSTR is a simple typedef for a wide-character string used as the principle
53 * string type in ole automation. When encapsulated in a Variant type they are
54 * automatically copied and destroyed as the variant is processed.
56 * The low level BSTR API allows manipulation of these strings and is used by
57 * higher level API calls to manage the strings transparently to the caller.
59 * Internally the BSTR type is allocated with space for a DWORD byte count before
60 * the string data begins. This is undocumented and non-system code should not
61 * access the count directly. Use SysStringLen() or SysStringByteLen()
62 * instead. Note that the byte count does not include the terminating NUL.
64 * To create a new BSTR, use SysAllocString(), SysAllocStringLen() or
65 * SysAllocStringByteLen(). To change the size of an existing BSTR, use SysReAllocString()
66 * or SysReAllocStringLen(). Finally to destroy a string use SysFreeString().
68 * BSTR's are cached by Ole Automation by default. To override this behaviour
69 * either set the environment variable 'OANOCACHE', or call SetOaNoCache().
72 * 'Inside OLE, second edition' by Kraig Brockshmidt.
75 static BOOL bstr_cache_enabled
;
77 static CRITICAL_SECTION cs_bstr_cache
;
78 static CRITICAL_SECTION_DEBUG cs_bstr_cache_dbg
=
81 { &cs_bstr_cache_dbg
.ProcessLocksList
, &cs_bstr_cache_dbg
.ProcessLocksList
},
82 0, 0, { (DWORD_PTR
)(__FILE__
": bstr_cache") }
84 static CRITICAL_SECTION cs_bstr_cache
= { &cs_bstr_cache_dbg
, -1, 0, 0, 0, 0 };
98 #define BUCKET_SIZE 16
99 #define BUCKET_BUFFER_SIZE 6
104 bstr_t
*buf
[BUCKET_BUFFER_SIZE
];
105 } bstr_cache_entry_t
;
107 #define ARENA_INUSE_FILLER 0x55
108 #define ARENA_TAIL_FILLER 0xab
109 #define ARENA_FREE_FILLER 0xfeeefeee
111 static bstr_cache_entry_t bstr_cache
[0x10000/BUCKET_SIZE
];
113 static inline size_t bstr_alloc_size(size_t size
)
115 return (FIELD_OFFSET(bstr_t
, u
.ptr
[size
]) + sizeof(WCHAR
) + BUCKET_SIZE
-1) & ~(BUCKET_SIZE
-1);
118 static inline bstr_t
*bstr_from_str(BSTR str
)
120 return CONTAINING_RECORD(str
, bstr_t
, u
.str
);
123 static inline bstr_cache_entry_t
*get_cache_entry_from_idx(unsigned cache_idx
)
125 return bstr_cache_enabled
&& cache_idx
< sizeof(bstr_cache
)/sizeof(*bstr_cache
)
126 ? bstr_cache
+ cache_idx
130 static inline bstr_cache_entry_t
*get_cache_entry(size_t size
)
132 unsigned cache_idx
= FIELD_OFFSET(bstr_t
, u
.ptr
[size
+sizeof(WCHAR
)-1])/BUCKET_SIZE
;
133 return get_cache_entry_from_idx(cache_idx
);
136 static inline bstr_cache_entry_t
*get_cache_entry_from_alloc_size(SIZE_T alloc_size
)
139 if (alloc_size
< BUCKET_SIZE
) return NULL
;
140 cache_idx
= (alloc_size
- BUCKET_SIZE
) / BUCKET_SIZE
;
141 return get_cache_entry_from_idx(cache_idx
);
144 static bstr_t
*alloc_bstr(size_t size
)
146 bstr_cache_entry_t
*cache_entry
= get_cache_entry(size
);
150 EnterCriticalSection(&cs_bstr_cache
);
152 if(!cache_entry
->cnt
) {
153 cache_entry
= get_cache_entry(size
+BUCKET_SIZE
);
154 if(cache_entry
&& !cache_entry
->cnt
)
159 ret
= cache_entry
->buf
[cache_entry
->head
++];
160 cache_entry
->head
%= BUCKET_BUFFER_SIZE
;
164 LeaveCriticalSection(&cs_bstr_cache
);
168 size_t fill_size
= (FIELD_OFFSET(bstr_t
, u
.ptr
[size
])+2*sizeof(WCHAR
)-1) & ~(sizeof(WCHAR
)-1);
169 memset(ret
, ARENA_INUSE_FILLER
, fill_size
);
170 memset((char *)ret
+fill_size
, ARENA_TAIL_FILLER
, bstr_alloc_size(size
)-fill_size
);
177 ret
= CoTaskMemAlloc(bstr_alloc_size(size
));
183 /******************************************************************************
184 * SysStringLen [OLEAUT32.7]
186 * Get the allocated length of a BSTR in wide characters.
189 * str [I] BSTR to find the length of
192 * The allocated length of str, or 0 if str is NULL.
196 * The returned length may be different from the length of the string as
197 * calculated by lstrlenW(), since it returns the length that was used to
198 * allocate the string by SysAllocStringLen().
200 UINT WINAPI
SysStringLen(BSTR str
)
202 return str
? bstr_from_str(str
)->size
/sizeof(WCHAR
) : 0;
205 /******************************************************************************
206 * SysStringByteLen [OLEAUT32.149]
208 * Get the allocated length of a BSTR in bytes.
211 * str [I] BSTR to find the length of
214 * The allocated length of str, or 0 if str is NULL.
217 * See SysStringLen(), BSTR().
219 UINT WINAPI
SysStringByteLen(BSTR str
)
221 return str
? bstr_from_str(str
)->size
: 0;
224 /******************************************************************************
225 * SysAllocString [OLEAUT32.2]
227 * Create a BSTR from an OLESTR.
230 * str [I] Source to create BSTR from
233 * Success: A BSTR allocated with SysAllocStringLen().
234 * Failure: NULL, if oleStr is NULL.
238 * MSDN (October 2001) incorrectly states that NULL is returned if oleStr has
239 * a length of 0. Native Win32 and this implementation both return a valid
240 * empty BSTR in this case.
242 BSTR WINAPI
SysAllocString(LPCOLESTR str
)
246 /* Delegate this to the SysAllocStringLen32 method. */
247 return SysAllocStringLen(str
, lstrlenW(str
));
250 static inline IMalloc
*get_malloc(void)
252 static IMalloc
*malloc
;
255 CoGetMalloc(1, &malloc
);
260 /******************************************************************************
261 * SysFreeString [OLEAUT32.6]
266 * str [I] BSTR to free.
273 * str may be NULL, in which case this function does nothing.
275 void WINAPI
SysFreeString(BSTR str
)
277 bstr_cache_entry_t
*cache_entry
;
279 IMalloc
*malloc
= get_malloc();
285 bstr
= bstr_from_str(str
);
287 alloc_size
= IMalloc_GetSize(malloc
, bstr
);
288 if (alloc_size
== ~0UL)
291 cache_entry
= get_cache_entry_from_alloc_size(alloc_size
);
295 EnterCriticalSection(&cs_bstr_cache
);
297 /* According to tests, freeing a string that's already in cache doesn't corrupt anything.
298 * For that to work we need to search the cache. */
299 for(i
=0; i
< cache_entry
->cnt
; i
++) {
300 if(cache_entry
->buf
[(cache_entry
->head
+i
) % BUCKET_BUFFER_SIZE
] == bstr
) {
301 WARN_(heap
)("String already is in cache!\n");
302 LeaveCriticalSection(&cs_bstr_cache
);
307 if(cache_entry
->cnt
< sizeof(cache_entry
->buf
)/sizeof(*cache_entry
->buf
)) {
308 cache_entry
->buf
[(cache_entry
->head
+cache_entry
->cnt
) % BUCKET_BUFFER_SIZE
] = bstr
;
312 unsigned n
= (alloc_size
-FIELD_OFFSET(bstr_t
, u
.ptr
))/sizeof(DWORD
);
314 bstr
->u
.dwptr
[i
] = ARENA_FREE_FILLER
;
317 LeaveCriticalSection(&cs_bstr_cache
);
321 LeaveCriticalSection(&cs_bstr_cache
);
327 /******************************************************************************
328 * SysAllocStringLen [OLEAUT32.4]
330 * Create a BSTR from an OLESTR of a given wide character length.
333 * str [I] Source to create BSTR from
334 * len [I] Length of oleStr in wide characters
337 * Success: A newly allocated BSTR from SysAllocStringByteLen()
338 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
341 * See BSTR(), SysAllocStringByteLen().
343 BSTR WINAPI
SysAllocStringLen(const OLECHAR
*str
, unsigned int len
)
348 /* Detect integer overflow. */
349 if (len
>= ((UINT_MAX
-sizeof(WCHAR
)-sizeof(DWORD
))/sizeof(WCHAR
)))
352 TRACE("%s\n", debugstr_wn(str
, len
));
354 size
= len
*sizeof(WCHAR
);
355 bstr
= alloc_bstr(size
);
360 memcpy(bstr
->u
.str
, str
, size
);
361 bstr
->u
.str
[len
] = 0;
363 memset(bstr
->u
.str
, 0, size
+sizeof(WCHAR
));
369 /******************************************************************************
370 * SysReAllocStringLen [OLEAUT32.5]
372 * Change the length of a previously created BSTR.
375 * old [O] BSTR to change the length of
376 * str [I] New source for pbstr
377 * len [I] Length of oleStr in wide characters
380 * Success: 1. The size of pbstr is updated.
381 * Failure: 0, if len >= 0x80000000 or memory allocation fails.
384 * See BSTR(), SysAllocStringByteLen().
385 * *old may be changed by this function.
387 int WINAPI
SysReAllocStringLen(BSTR
* old
, const OLECHAR
* str
, unsigned int len
)
389 /* Detect integer overflow. */
390 if (len
>= ((UINT_MAX
-sizeof(WCHAR
)-sizeof(DWORD
))/sizeof(WCHAR
)))
394 DWORD newbytelen
= len
*sizeof(WCHAR
);
395 bstr_t
*old_bstr
= bstr_from_str(*old
);
396 bstr_t
*bstr
= CoTaskMemRealloc(old_bstr
, bstr_alloc_size(newbytelen
));
398 if (!bstr
) return FALSE
;
401 bstr
->size
= newbytelen
;
402 /* The old string data is still there when str is NULL */
403 if (str
&& old_bstr
->u
.str
!= str
) memmove(bstr
->u
.str
, str
, newbytelen
);
404 bstr
->u
.str
[len
] = 0;
406 *old
= SysAllocStringLen(str
, len
);
412 /******************************************************************************
413 * SysAllocStringByteLen [OLEAUT32.150]
415 * Create a BSTR from an OLESTR of a given byte length.
418 * str [I] Source to create BSTR from
419 * len [I] Length of oleStr in bytes
422 * Success: A newly allocated BSTR
423 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
426 * -If len is 0 or oleStr is NULL the resulting string is empty ("").
427 * -This function always NUL terminates the resulting BSTR.
428 * -oleStr may be either an LPCSTR or LPCOLESTR, since it is copied
429 * without checking for a terminating NUL.
432 BSTR WINAPI
SysAllocStringByteLen(LPCSTR str
, UINT len
)
436 /* Detect integer overflow. */
437 if (len
>= (UINT_MAX
-sizeof(WCHAR
)-sizeof(DWORD
)))
440 bstr
= alloc_bstr(len
);
445 memcpy(bstr
->u
.ptr
, str
, len
);
446 bstr
->u
.ptr
[len
] = 0;
448 memset(bstr
->u
.ptr
, 0, len
+1);
450 bstr
->u
.str
[(len
+sizeof(WCHAR
)-1)/sizeof(WCHAR
)] = 0;
455 /******************************************************************************
456 * SysReAllocString [OLEAUT32.3]
458 * Change the length of a previously created BSTR.
461 * old [I/O] BSTR to change the length of
462 * str [I] New source for pbstr
469 * See BSTR(), SysAllocStringStringLen().
471 INT WINAPI
SysReAllocString(LPBSTR old
,LPCOLESTR str
)
480 * Make sure we free the old string.
485 * Allocate the new string
487 *old
= SysAllocString(str
);
492 /******************************************************************************
493 * SetOaNoCache (OLEAUT32.327)
495 * Instruct Ole Automation not to cache BSTR allocations.
504 * SetOaNoCache does not release cached strings, so it leaks by design.
506 void WINAPI
SetOaNoCache(void)
509 bstr_cache_enabled
= FALSE
;
512 static const WCHAR _delimiter
[] = {'!',0}; /* default delimiter apparently */
513 static const WCHAR
*pdelimiter
= &_delimiter
[0];
515 /***********************************************************************
516 * RegisterActiveObject (OLEAUT32.33)
518 * Registers an object in the global item table.
521 * punk [I] Object to register.
522 * rcid [I] CLSID of the object.
524 * pdwRegister [O] Address to store cookie of object registration in.
528 * Failure: HRESULT code.
530 HRESULT WINAPI DECLSPEC_HOTPATCH
RegisterActiveObject(
531 LPUNKNOWN punk
,REFCLSID rcid
,DWORD dwFlags
,LPDWORD pdwRegister
535 LPRUNNINGOBJECTTABLE runobtable
;
537 DWORD rot_flags
= ROTFLAGS_REGISTRATIONKEEPSALIVE
; /* default registration is strong */
539 StringFromGUID2(rcid
,guidbuf
,39);
540 ret
= CreateItemMoniker(pdelimiter
,guidbuf
,&moniker
);
543 ret
= GetRunningObjectTable(0,&runobtable
);
545 IMoniker_Release(moniker
);
548 if(dwFlags
== ACTIVEOBJECT_WEAK
)
550 ret
= IRunningObjectTable_Register(runobtable
,rot_flags
,punk
,moniker
,pdwRegister
);
551 IRunningObjectTable_Release(runobtable
);
552 IMoniker_Release(moniker
);
556 /***********************************************************************
557 * RevokeActiveObject (OLEAUT32.34)
559 * Revokes an object from the global item table.
562 * xregister [I] Registration cookie.
563 * reserved [I] Reserved. Set to NULL.
567 * Failure: HRESULT code.
569 HRESULT WINAPI DECLSPEC_HOTPATCH
RevokeActiveObject(DWORD xregister
,LPVOID reserved
)
571 LPRUNNINGOBJECTTABLE runobtable
;
574 ret
= GetRunningObjectTable(0,&runobtable
);
575 if (FAILED(ret
)) return ret
;
576 ret
= IRunningObjectTable_Revoke(runobtable
,xregister
);
577 if (SUCCEEDED(ret
)) ret
= S_OK
;
578 IRunningObjectTable_Release(runobtable
);
582 /***********************************************************************
583 * GetActiveObject (OLEAUT32.35)
585 * Gets an object from the global item table.
588 * rcid [I] CLSID of the object.
589 * preserved [I] Reserved. Set to NULL.
590 * ppunk [O] Address to store object into.
594 * Failure: HRESULT code.
596 HRESULT WINAPI DECLSPEC_HOTPATCH
GetActiveObject(REFCLSID rcid
,LPVOID preserved
,LPUNKNOWN
*ppunk
)
600 LPRUNNINGOBJECTTABLE runobtable
;
603 StringFromGUID2(rcid
,guidbuf
,39);
604 ret
= CreateItemMoniker(pdelimiter
,guidbuf
,&moniker
);
607 ret
= GetRunningObjectTable(0,&runobtable
);
609 IMoniker_Release(moniker
);
612 ret
= IRunningObjectTable_GetObject(runobtable
,moniker
,ppunk
);
613 IRunningObjectTable_Release(runobtable
);
614 IMoniker_Release(moniker
);
619 /***********************************************************************
620 * OaBuildVersion [OLEAUT32.170]
622 * Get the Ole Automation build version.
631 * Known oleaut32.dll versions:
632 *| OLE Ver. Comments Date Build Ver.
633 *| -------- ------------------------- ---- ---------
634 *| OLE 2.1 NT 1993-95 10 3023
636 *| Win32s Ver 1.1e 20 4049
637 *| OLE 2.20 W95/NT 1993-96 20 4112
638 *| OLE 2.20 W95/NT 1993-96 20 4118
639 *| OLE 2.20 W95/NT 1993-96 20 4122
640 *| OLE 2.30 W95/NT 1993-98 30 4265
641 *| OLE 2.40 NT?? 1993-98 40 4267
642 *| OLE 2.40 W98 SE orig. file 1993-98 40 4275
643 *| OLE 2.40 W2K orig. file 1993-XX 40 4514
645 * Currently the versions returned are 2.20 for Win3.1, 2.30 for Win95 & NT 3.51,
646 * and 2.40 for all later versions. The build number is maximum, i.e. 0xffff.
648 ULONG WINAPI
OaBuildVersion(void)
650 switch(GetVersion() & 0x8000ffff) /* mask off build number */
652 case 0x80000a03: /* WIN31 */
653 return MAKELONG(0xffff, 20);
654 case 0x00003303: /* NT351 */
655 return MAKELONG(0xffff, 30);
656 case 0x80000004: /* WIN95; I'd like to use the "standard" w95 minor
657 version here (30), but as we still use w95
658 as default winver (which is good IMHO), I better
659 play safe and use the latest value for w95 for now.
660 Change this as soon as default winver gets changed
661 to something more recent */
662 case 0x80000a04: /* WIN98 */
663 case 0x00000004: /* NT40 */
664 case 0x00000005: /* W2K */
665 return MAKELONG(0xffff, 40);
666 case 0x00000105: /* WinXP */
667 case 0x00000006: /* Vista */
668 case 0x00000106: /* Win7 */
669 return MAKELONG(0xffff, 50);
671 FIXME("Version value not known yet. Please investigate it !\n");
672 return MAKELONG(0xffff, 40); /* for now return the same value as for w2k */
676 /******************************************************************************
677 * OleTranslateColor [OLEAUT32.421]
679 * Convert an OLE_COLOR to a COLORREF.
682 * clr [I] Color to convert
683 * hpal [I] Handle to a palette for the conversion
684 * pColorRef [O] Destination for converted color, or NULL to test if the conversion is ok
687 * Success: S_OK. The conversion is ok, and pColorRef contains the converted color if non-NULL.
688 * Failure: E_INVALIDARG, if any argument is invalid.
691 * Document the conversion rules.
693 HRESULT WINAPI
OleTranslateColor(
699 BYTE b
= HIBYTE(HIWORD(clr
));
701 TRACE("(%08x, %p, %p)\n", clr
, hpal
, pColorRef
);
704 * In case pColorRef is NULL, provide our own to simplify the code.
706 if (pColorRef
== NULL
)
707 pColorRef
= &colorref
;
714 *pColorRef
= PALETTERGB(GetRValue(clr
),
729 * Validate the palette index.
731 if (GetPaletteEntries(hpal
, LOWORD(clr
), 1, &pe
) == 0)
746 int index
= LOBYTE(LOWORD(clr
));
749 * Validate GetSysColor index.
751 if ((index
< COLOR_SCROLLBAR
) || (index
> COLOR_MENUBAR
))
754 *pColorRef
= GetSysColor(index
);
766 extern HRESULT WINAPI
OLEAUTPS_DllGetClassObject(REFCLSID
, REFIID
, LPVOID
*) DECLSPEC_HIDDEN
;
767 extern BOOL WINAPI
OLEAUTPS_DllMain(HINSTANCE
, DWORD
, LPVOID
) DECLSPEC_HIDDEN
;
768 extern HRESULT WINAPI
OLEAUTPS_DllRegisterServer(void) DECLSPEC_HIDDEN
;
769 extern HRESULT WINAPI
OLEAUTPS_DllUnregisterServer(void) DECLSPEC_HIDDEN
;
771 extern void _get_STDFONT_CF(LPVOID
*);
772 extern void _get_STDPIC_CF(LPVOID
*);
774 static HRESULT WINAPI
PSDispatchFacBuf_QueryInterface(IPSFactoryBuffer
*iface
, REFIID riid
, void **ppv
)
776 if (IsEqualIID(riid
, &IID_IUnknown
) ||
777 IsEqualIID(riid
, &IID_IPSFactoryBuffer
))
779 IPSFactoryBuffer_AddRef(iface
);
783 return E_NOINTERFACE
;
786 static ULONG WINAPI
PSDispatchFacBuf_AddRef(IPSFactoryBuffer
*iface
)
791 static ULONG WINAPI
PSDispatchFacBuf_Release(IPSFactoryBuffer
*iface
)
796 static HRESULT WINAPI
PSDispatchFacBuf_CreateProxy(IPSFactoryBuffer
*iface
, IUnknown
*pUnkOuter
, REFIID riid
, IRpcProxyBuffer
**ppProxy
, void **ppv
)
798 IPSFactoryBuffer
*pPSFB
;
801 if (IsEqualIID(riid
, &IID_IDispatch
))
802 hr
= OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer
, &IID_IPSFactoryBuffer
, (void **)&pPSFB
);
804 hr
= TMARSHAL_DllGetClassObject(&CLSID_PSOAInterface
, &IID_IPSFactoryBuffer
, (void **)&pPSFB
);
806 if (FAILED(hr
)) return hr
;
808 hr
= IPSFactoryBuffer_CreateProxy(pPSFB
, pUnkOuter
, riid
, ppProxy
, ppv
);
810 IPSFactoryBuffer_Release(pPSFB
);
814 static HRESULT WINAPI
PSDispatchFacBuf_CreateStub(IPSFactoryBuffer
*iface
, REFIID riid
, IUnknown
*pUnkOuter
, IRpcStubBuffer
**ppStub
)
816 IPSFactoryBuffer
*pPSFB
;
819 if (IsEqualIID(riid
, &IID_IDispatch
))
820 hr
= OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer
, &IID_IPSFactoryBuffer
, (void **)&pPSFB
);
822 hr
= TMARSHAL_DllGetClassObject(&CLSID_PSOAInterface
, &IID_IPSFactoryBuffer
, (void **)&pPSFB
);
824 if (FAILED(hr
)) return hr
;
826 hr
= IPSFactoryBuffer_CreateStub(pPSFB
, riid
, pUnkOuter
, ppStub
);
828 IPSFactoryBuffer_Release(pPSFB
);
832 static const IPSFactoryBufferVtbl PSDispatchFacBuf_Vtbl
=
834 PSDispatchFacBuf_QueryInterface
,
835 PSDispatchFacBuf_AddRef
,
836 PSDispatchFacBuf_Release
,
837 PSDispatchFacBuf_CreateProxy
,
838 PSDispatchFacBuf_CreateStub
841 /* This is the whole PSFactoryBuffer object, just the vtableptr */
842 static const IPSFactoryBufferVtbl
*pPSDispatchFacBuf
= &PSDispatchFacBuf_Vtbl
;
844 /***********************************************************************
845 * DllGetClassObject (OLEAUT32.@)
847 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
850 if (IsEqualGUID(rclsid
,&CLSID_StdFont
)) {
851 if (IsEqualGUID(iid
,&IID_IClassFactory
)) {
852 _get_STDFONT_CF(ppv
);
853 IClassFactory_AddRef((IClassFactory
*)*ppv
);
857 if (IsEqualGUID(rclsid
,&CLSID_StdPicture
)) {
858 if (IsEqualGUID(iid
,&IID_IClassFactory
)) {
860 IClassFactory_AddRef((IClassFactory
*)*ppv
);
864 if (IsEqualCLSID(rclsid
, &CLSID_PSDispatch
) && IsEqualIID(iid
, &IID_IPSFactoryBuffer
)) {
865 *ppv
= &pPSDispatchFacBuf
;
866 IPSFactoryBuffer_AddRef((IPSFactoryBuffer
*)*ppv
);
869 if (IsEqualGUID(rclsid
,&CLSID_PSOAInterface
)) {
870 if (S_OK
==TMARSHAL_DllGetClassObject(rclsid
,iid
,ppv
))
874 if (IsEqualCLSID(rclsid
, &CLSID_PSTypeComp
) ||
875 IsEqualCLSID(rclsid
, &CLSID_PSTypeInfo
) ||
876 IsEqualCLSID(rclsid
, &CLSID_PSTypeLib
) ||
877 IsEqualCLSID(rclsid
, &CLSID_PSDispatch
) ||
878 IsEqualCLSID(rclsid
, &CLSID_PSEnumVariant
))
879 return OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer
, iid
, ppv
);
881 return OLEAUTPS_DllGetClassObject(rclsid
, iid
, ppv
);
884 /***********************************************************************
885 * DllCanUnloadNow (OLEAUT32.@)
887 * Determine if this dll can be unloaded from the callers address space.
893 * Always returns S_FALSE. This dll cannot be unloaded.
895 HRESULT WINAPI
DllCanUnloadNow(void)
900 /*****************************************************************************
901 * DllMain [OLEAUT32.@]
903 BOOL WINAPI
DllMain(HINSTANCE hInstDll
, DWORD fdwReason
, LPVOID lpvReserved
)
905 static const WCHAR oanocacheW
[] = {'o','a','n','o','c','a','c','h','e',0};
907 if(fdwReason
== DLL_PROCESS_ATTACH
)
908 bstr_cache_enabled
= !GetEnvironmentVariableW(oanocacheW
, NULL
, 0);
910 return OLEAUTPS_DllMain( hInstDll
, fdwReason
, lpvReserved
);
913 /***********************************************************************
914 * DllRegisterServer (OLEAUT32.@)
916 HRESULT WINAPI
DllRegisterServer(void)
918 return OLEAUTPS_DllRegisterServer();
921 /***********************************************************************
922 * DllUnregisterServer (OLEAUT32.@)
924 HRESULT WINAPI
DllUnregisterServer(void)
926 return OLEAUTPS_DllUnregisterServer();
929 /***********************************************************************
930 * OleIconToCursor (OLEAUT32.415)
932 HCURSOR WINAPI
OleIconToCursor( HINSTANCE hinstExe
, HICON hIcon
)
934 FIXME("(%p,%p), partially implemented.\n",hinstExe
,hIcon
);
935 /* FIXME: make an extended conversation from HICON to HCURSOR */
936 return CopyCursor(hIcon
);