regedit: An English (United States) spelling fix.
[wine/multimedia.git] / dlls / oleaut32 / oleaut.c
blob0586e1508164c6b4527f15df5bc73968b39dcc7b
1 /*
2 * OLEAUT32
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
21 #include <stdarg.h>
22 #include <string.h>
23 #include <limits.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winerror.h"
33 #include "ole2.h"
34 #include "olectl.h"
35 #include "oleauto.h"
36 #include "initguid.h"
37 #include "typelib.h"
38 #include "oleaut32_oaidl.h"
40 #include "wine/debug.h"
41 #include "wine/unicode.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(ole);
45 static BOOL BSTR_bCache = TRUE; /* Cache allocations to minimise alloc calls? */
47 /******************************************************************************
48 * BSTR {OLEAUT32}
50 * NOTES
51 * BSTR is a simple typedef for a wide-character string used as the principle
52 * string type in ole automation. When encapsulated in a Variant type they are
53 * automatically copied and destroyed as the variant is processed.
55 * The low level BSTR Api allows manipulation of these strings and is used by
56 * higher level Api calls to manage the strings transparently to the caller.
58 * Internally the BSTR type is allocated with space for a DWORD byte count before
59 * the string data begins. This is undocumented and non-system code should not
60 * access the count directly. Use SysStringLen() or SysStringByteLen()
61 * instead. Note that the byte count does not include the terminating NUL.
63 * To create a new BSTR, use SysAllocString(), SysAllocStringLen() or
64 * SysAllocStringByteLen(). To change the size of an existing BSTR, use SysReAllocString()
65 * or SysReAllocStringLen(). Finally to destroy a string use SysFreeString().
67 * BSTR's are cached by Ole Automation by default. To override this behaviour
68 * either set the environment variable 'OANOCACHE', or call SetOaNoCache().
70 * SEE ALSO
71 * 'Inside OLE, second edition' by Kraig Brockshmidt.
74 /******************************************************************************
75 * SysStringLen [OLEAUT32.7]
77 * Get the allocated length of a BSTR in wide characters.
79 * PARAMS
80 * str [I] BSTR to find the length of
82 * RETURNS
83 * The allocated length of str, or 0 if str is NULL.
85 * NOTES
86 * See BSTR.
87 * The returned length may be different from the length of the string as
88 * calculated by lstrlenW(), since it returns the length that was used to
89 * allocate the string by SysAllocStringLen().
91 UINT WINAPI SysStringLen(BSTR str)
93 DWORD* bufferPointer;
95 if (!str) return 0;
97 * The length of the string (in bytes) is contained in a DWORD placed
98 * just before the BSTR pointer
100 bufferPointer = (DWORD*)str;
102 bufferPointer--;
104 return (int)(*bufferPointer/sizeof(WCHAR));
107 /******************************************************************************
108 * SysStringByteLen [OLEAUT32.149]
110 * Get the allocated length of a BSTR in bytes.
112 * PARAMS
113 * str [I] BSTR to find the length of
115 * RETURNS
116 * The allocated length of str, or 0 if str is NULL.
118 * NOTES
119 * See SysStringLen(), BSTR().
121 UINT WINAPI SysStringByteLen(BSTR str)
123 DWORD* bufferPointer;
125 if (!str) return 0;
127 * The length of the string (in bytes) is contained in a DWORD placed
128 * just before the BSTR pointer
130 bufferPointer = (DWORD*)str;
132 bufferPointer--;
134 return (int)(*bufferPointer);
137 /******************************************************************************
138 * SysAllocString [OLEAUT32.2]
140 * Create a BSTR from an OLESTR.
142 * PARAMS
143 * str [I] Source to create BSTR from
145 * RETURNS
146 * Success: A BSTR allocated with SysAllocStringLen().
147 * Failure: NULL, if oleStr is NULL.
149 * NOTES
150 * See BSTR.
151 * MSDN (October 2001) incorrectly states that NULL is returned if oleStr has
152 * a length of 0. Native Win32 and this implementation both return a valid
153 * empty BSTR in this case.
155 BSTR WINAPI SysAllocString(LPCOLESTR str)
157 if (!str) return 0;
159 /* Delegate this to the SysAllocStringLen32 method. */
160 return SysAllocStringLen(str, lstrlenW(str));
163 /******************************************************************************
164 * SysFreeString [OLEAUT32.6]
166 * Free a BSTR.
168 * PARAMS
169 * str [I] BSTR to free.
171 * RETURNS
172 * Nothing.
174 * NOTES
175 * See BSTR.
176 * str may be NULL, in which case this function does nothing.
178 void WINAPI SysFreeString(BSTR str)
180 DWORD* bufferPointer;
182 /* NULL is a valid parameter */
183 if(!str) return;
186 * We have to be careful when we free a BSTR pointer, it points to
187 * the beginning of the string but it skips the byte count contained
188 * before the string.
190 bufferPointer = (DWORD*)str;
192 bufferPointer--;
195 * Free the memory from its "real" origin.
197 HeapFree(GetProcessHeap(), 0, bufferPointer);
200 /******************************************************************************
201 * SysAllocStringLen [OLEAUT32.4]
203 * Create a BSTR from an OLESTR of a given wide character length.
205 * PARAMS
206 * str [I] Source to create BSTR from
207 * len [I] Length of oleStr in wide characters
209 * RETURNS
210 * Success: A newly allocated BSTR from SysAllocStringByteLen()
211 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
213 * NOTES
214 * See BSTR(), SysAllocStringByteLen().
216 BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
218 DWORD bufferSize;
219 DWORD* newBuffer;
220 WCHAR* stringBuffer;
222 /* Detect integer overflow. */
223 if (len >= ((UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))/sizeof(WCHAR)))
224 return NULL;
226 * Find the length of the buffer passed-in, in bytes.
228 bufferSize = len * sizeof (WCHAR);
231 * Allocate a new buffer to hold the string.
232 * don't forget to keep an empty spot at the beginning of the
233 * buffer for the character count and an extra character at the
234 * end for the NULL.
236 newBuffer = HeapAlloc(GetProcessHeap(), 0,
237 bufferSize + sizeof(WCHAR) + sizeof(DWORD));
240 * If the memory allocation failed, return a null pointer.
242 if (!newBuffer)
243 return NULL;
246 * Copy the length of the string in the placeholder.
248 *newBuffer = bufferSize;
251 * Skip the byte count.
253 newBuffer++;
256 * Copy the information in the buffer.
257 * Since it is valid to pass a NULL pointer here, we'll initialize the
258 * buffer to nul if it is the case.
260 if (str != 0)
261 memcpy(newBuffer, str, bufferSize);
262 else
263 memset(newBuffer, 0, bufferSize);
266 * Make sure that there is a nul character at the end of the
267 * string.
269 stringBuffer = (WCHAR*)newBuffer;
270 stringBuffer[len] = '\0';
272 return stringBuffer;
275 /******************************************************************************
276 * SysReAllocStringLen [OLEAUT32.5]
278 * Change the length of a previously created BSTR.
280 * PARAMS
281 * old [O] BSTR to change the length of
282 * str [I] New source for pbstr
283 * len [I] Length of oleStr in wide characters
285 * RETURNS
286 * Success: 1. The size of pbstr is updated.
287 * Failure: 0, if len >= 0x80000000 or memory allocation fails.
289 * NOTES
290 * See BSTR(), SysAllocStringByteLen().
291 * *old may be changed by this function.
293 int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* str, unsigned int len)
295 /* Detect integer overflow. */
296 if (len >= ((UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))/sizeof(WCHAR)))
297 return 0;
299 if (*old!=NULL) {
300 BSTR old_copy = *old;
301 DWORD newbytelen = len*sizeof(WCHAR);
302 DWORD *ptr = HeapReAlloc(GetProcessHeap(),0,((DWORD*)*old)-1,newbytelen+sizeof(WCHAR)+sizeof(DWORD));
303 *old = (BSTR)(ptr+1);
304 *ptr = newbytelen;
305 /* Subtle hidden feature: The old string data is still there
306 * when 'in' is NULL!
307 * Some Microsoft program needs it.
309 if (str && old_copy!=str) memmove(*old, str, newbytelen);
310 (*old)[len] = 0;
311 } else {
313 * Allocate the new string
315 *old = SysAllocStringLen(str, len);
318 return 1;
321 /******************************************************************************
322 * SysAllocStringByteLen [OLEAUT32.150]
324 * Create a BSTR from an OLESTR of a given byte length.
326 * PARAMS
327 * str [I] Source to create BSTR from
328 * len [I] Length of oleStr in bytes
330 * RETURNS
331 * Success: A newly allocated BSTR
332 * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
334 * NOTES
335 * -If len is 0 or oleStr is NULL the resulting string is empty ("").
336 * -This function always NUL terminates the resulting BSTR.
337 * -oleStr may be either an LPCSTR or LPCOLESTR, since it is copied
338 * without checking for a terminating NUL.
339 * See BSTR.
341 BSTR WINAPI SysAllocStringByteLen(LPCSTR str, UINT len)
343 DWORD* newBuffer;
344 char* stringBuffer;
346 /* Detect integer overflow. */
347 if (len >= (UINT_MAX-sizeof(WCHAR)-sizeof(DWORD)))
348 return NULL;
351 * Allocate a new buffer to hold the string.
352 * don't forget to keep an empty spot at the beginning of the
353 * buffer for the character count and an extra character at the
354 * end for the NULL.
356 newBuffer = HeapAlloc(GetProcessHeap(), 0,
357 len + sizeof(WCHAR) + sizeof(DWORD));
360 * If the memory allocation failed, return a null pointer.
362 if (newBuffer==0)
363 return 0;
366 * Copy the length of the string in the placeholder.
368 *newBuffer = len;
371 * Skip the byte count.
373 newBuffer++;
376 * Copy the information in the buffer.
377 * Since it is valid to pass a NULL pointer here, we'll initialize the
378 * buffer to nul if it is the case.
380 if (str != 0)
381 memcpy(newBuffer, str, len);
384 * Make sure that there is a nul character at the end of the
385 * string.
387 stringBuffer = (char *)newBuffer;
388 stringBuffer[len] = 0;
389 stringBuffer[len+1] = 0;
391 return (LPWSTR)stringBuffer;
394 /******************************************************************************
395 * SysReAllocString [OLEAUT32.3]
397 * Change the length of a previously created BSTR.
399 * PARAMS
400 * old [I/O] BSTR to change the length of
401 * str [I] New source for pbstr
403 * RETURNS
404 * Success: 1
405 * Failure: 0.
407 * NOTES
408 * See BSTR(), SysAllocStringStringLen().
410 INT WINAPI SysReAllocString(LPBSTR old,LPCOLESTR str)
413 * Sanity check
415 if (old==NULL)
416 return 0;
419 * Make sure we free the old string.
421 SysFreeString(*old);
424 * Allocate the new string
426 *old = SysAllocString(str);
428 return 1;
431 /******************************************************************************
432 * SetOaNoCache (OLEAUT32.327)
434 * Instruct Ole Automation not to cache BSTR allocations.
436 * PARAMS
437 * None.
439 * RETURNS
440 * Nothing.
442 * NOTES
443 * See BSTR.
445 void WINAPI SetOaNoCache(void)
447 BSTR_bCache = FALSE;
450 static const WCHAR _delimiter[] = {'!',0}; /* default delimiter apparently */
451 static const WCHAR *pdelimiter = &_delimiter[0];
453 /***********************************************************************
454 * RegisterActiveObject (OLEAUT32.33)
456 * Registers an object in the global item table.
458 * PARAMS
459 * punk [I] Object to register.
460 * rcid [I] CLSID of the object.
461 * dwFlags [I] Flags.
462 * pdwRegister [O] Address to store cookie of object registration in.
464 * RETURNS
465 * Success: S_OK.
466 * Failure: HRESULT code.
468 HRESULT WINAPI RegisterActiveObject(
469 LPUNKNOWN punk,REFCLSID rcid,DWORD dwFlags,LPDWORD pdwRegister
471 WCHAR guidbuf[80];
472 HRESULT ret;
473 LPRUNNINGOBJECTTABLE runobtable;
474 LPMONIKER moniker;
475 DWORD rot_flags = ROTFLAGS_REGISTRATIONKEEPSALIVE; /* default registration is strong */
477 StringFromGUID2(rcid,guidbuf,39);
478 ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
479 if (FAILED(ret))
480 return ret;
481 ret = GetRunningObjectTable(0,&runobtable);
482 if (FAILED(ret)) {
483 IMoniker_Release(moniker);
484 return ret;
486 if(dwFlags == ACTIVEOBJECT_WEAK)
487 rot_flags = 0;
488 ret = IRunningObjectTable_Register(runobtable,rot_flags,punk,moniker,pdwRegister);
489 IRunningObjectTable_Release(runobtable);
490 IMoniker_Release(moniker);
491 return ret;
494 /***********************************************************************
495 * RevokeActiveObject (OLEAUT32.34)
497 * Revokes an object from the global item table.
499 * PARAMS
500 * xregister [I] Registration cookie.
501 * reserved [I] Reserved. Set to NULL.
503 * RETURNS
504 * Success: S_OK.
505 * Failure: HRESULT code.
507 HRESULT WINAPI RevokeActiveObject(DWORD xregister,LPVOID reserved)
509 LPRUNNINGOBJECTTABLE runobtable;
510 HRESULT ret;
512 ret = GetRunningObjectTable(0,&runobtable);
513 if (FAILED(ret)) return ret;
514 ret = IRunningObjectTable_Revoke(runobtable,xregister);
515 if (SUCCEEDED(ret)) ret = S_OK;
516 IRunningObjectTable_Release(runobtable);
517 return ret;
520 /***********************************************************************
521 * GetActiveObject (OLEAUT32.35)
523 * Gets an object from the global item table.
525 * PARAMS
526 * rcid [I] CLSID of the object.
527 * preserved [I] Reserved. Set to NULL.
528 * ppunk [O] Address to store object into.
530 * RETURNS
531 * Success: S_OK.
532 * Failure: HRESULT code.
534 HRESULT WINAPI GetActiveObject(REFCLSID rcid,LPVOID preserved,LPUNKNOWN *ppunk)
536 WCHAR guidbuf[80];
537 HRESULT ret;
538 LPRUNNINGOBJECTTABLE runobtable;
539 LPMONIKER moniker;
541 StringFromGUID2(rcid,guidbuf,39);
542 ret = CreateItemMoniker(pdelimiter,guidbuf,&moniker);
543 if (FAILED(ret))
544 return ret;
545 ret = GetRunningObjectTable(0,&runobtable);
546 if (FAILED(ret)) {
547 IMoniker_Release(moniker);
548 return ret;
550 ret = IRunningObjectTable_GetObject(runobtable,moniker,ppunk);
551 IRunningObjectTable_Release(runobtable);
552 IMoniker_Release(moniker);
553 return ret;
557 /***********************************************************************
558 * OaBuildVersion [OLEAUT32.170]
560 * Get the Ole Automation build version.
562 * PARAMS
563 * None
565 * RETURNS
566 * The build version.
568 * NOTES
569 * Known oleaut32.dll versions:
570 *| OLE Ver. Comments Date Build Ver.
571 *| -------- ------------------------- ---- ---------
572 *| OLE 2.1 NT 1993-95 10 3023
573 *| OLE 2.1 10 3027
574 *| Win32s Ver 1.1e 20 4049
575 *| OLE 2.20 W95/NT 1993-96 20 4112
576 *| OLE 2.20 W95/NT 1993-96 20 4118
577 *| OLE 2.20 W95/NT 1993-96 20 4122
578 *| OLE 2.30 W95/NT 1993-98 30 4265
579 *| OLE 2.40 NT?? 1993-98 40 4267
580 *| OLE 2.40 W98 SE orig. file 1993-98 40 4275
581 *| OLE 2.40 W2K orig. file 1993-XX 40 4514
583 * Currently the versions returned are 2.20 for Win3.1, 2.30 for Win95 & NT 3.51,
584 * and 2.40 for all later versions. The build number is maximum, i.e. 0xffff.
586 ULONG WINAPI OaBuildVersion(void)
588 switch(GetVersion() & 0x8000ffff) /* mask off build number */
590 case 0x80000a03: /* WIN31 */
591 return MAKELONG(0xffff, 20);
592 case 0x00003303: /* NT351 */
593 return MAKELONG(0xffff, 30);
594 case 0x80000004: /* WIN95; I'd like to use the "standard" w95 minor
595 version here (30), but as we still use w95
596 as default winver (which is good IMHO), I better
597 play safe and use the latest value for w95 for now.
598 Change this as soon as default winver gets changed
599 to something more recent */
600 case 0x80000a04: /* WIN98 */
601 case 0x00000004: /* NT40 */
602 case 0x00000005: /* W2K */
603 return MAKELONG(0xffff, 40);
604 case 0x00000105: /* WinXP */
605 case 0x00000006: /* Vista */
606 case 0x00000106: /* Win7 */
607 return MAKELONG(0xffff, 50);
608 default:
609 FIXME("Version value not known yet. Please investigate it !\n");
610 return MAKELONG(0xffff, 40); /* for now return the same value as for w2k */
614 /******************************************************************************
615 * OleTranslateColor [OLEAUT32.421]
617 * Convert an OLE_COLOR to a COLORREF.
619 * PARAMS
620 * clr [I] Color to convert
621 * hpal [I] Handle to a palette for the conversion
622 * pColorRef [O] Destination for converted color, or NULL to test if the conversion is ok
624 * RETURNS
625 * Success: S_OK. The conversion is ok, and pColorRef contains the converted color if non-NULL.
626 * Failure: E_INVALIDARG, if any argument is invalid.
628 * FIXME
629 * Document the conversion rules.
631 HRESULT WINAPI OleTranslateColor(
632 OLE_COLOR clr,
633 HPALETTE hpal,
634 COLORREF* pColorRef)
636 COLORREF colorref;
637 BYTE b = HIBYTE(HIWORD(clr));
639 TRACE("(%08x, %p, %p)\n", clr, hpal, pColorRef);
642 * In case pColorRef is NULL, provide our own to simplify the code.
644 if (pColorRef == NULL)
645 pColorRef = &colorref;
647 switch (b)
649 case 0x00:
651 if (hpal != 0)
652 *pColorRef = PALETTERGB(GetRValue(clr),
653 GetGValue(clr),
654 GetBValue(clr));
655 else
656 *pColorRef = clr;
658 break;
661 case 0x01:
663 if (hpal != 0)
665 PALETTEENTRY pe;
667 * Validate the palette index.
669 if (GetPaletteEntries(hpal, LOWORD(clr), 1, &pe) == 0)
670 return E_INVALIDARG;
673 *pColorRef = clr;
675 break;
678 case 0x02:
679 *pColorRef = clr;
680 break;
682 case 0x80:
684 int index = LOBYTE(LOWORD(clr));
687 * Validate GetSysColor index.
689 if ((index < COLOR_SCROLLBAR) || (index > COLOR_MENUBAR))
690 return E_INVALIDARG;
692 *pColorRef = GetSysColor(index);
694 break;
697 default:
698 return E_INVALIDARG;
701 return S_OK;
704 extern HRESULT WINAPI OLEAUTPS_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
705 extern BOOL WINAPI OLEAUTPS_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
706 extern HRESULT WINAPI OLEAUTPS_DllRegisterServer(void) DECLSPEC_HIDDEN;
707 extern HRESULT WINAPI OLEAUTPS_DllUnregisterServer(void) DECLSPEC_HIDDEN;
708 extern GUID const CLSID_PSFactoryBuffer DECLSPEC_HIDDEN;
710 extern void _get_STDFONT_CF(LPVOID *);
711 extern void _get_STDPIC_CF(LPVOID *);
713 static HRESULT WINAPI PSDispatchFacBuf_QueryInterface(IPSFactoryBuffer *iface, REFIID riid, void **ppv)
715 if (IsEqualIID(riid, &IID_IUnknown) ||
716 IsEqualIID(riid, &IID_IPSFactoryBuffer))
718 IUnknown_AddRef(iface);
719 *ppv = iface;
720 return S_OK;
722 return E_NOINTERFACE;
725 static ULONG WINAPI PSDispatchFacBuf_AddRef(IPSFactoryBuffer *iface)
727 return 2;
730 static ULONG WINAPI PSDispatchFacBuf_Release(IPSFactoryBuffer *iface)
732 return 1;
735 static HRESULT WINAPI PSDispatchFacBuf_CreateProxy(IPSFactoryBuffer *iface, IUnknown *pUnkOuter, REFIID riid, IRpcProxyBuffer **ppProxy, void **ppv)
737 IPSFactoryBuffer *pPSFB;
738 HRESULT hr;
740 if (IsEqualIID(riid, &IID_IDispatch))
741 hr = OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, &IID_IPSFactoryBuffer, (void **)&pPSFB);
742 else
743 hr = TMARSHAL_DllGetClassObject(&CLSID_PSOAInterface, &IID_IPSFactoryBuffer, (void **)&pPSFB);
745 if (FAILED(hr)) return hr;
747 hr = IPSFactoryBuffer_CreateProxy(pPSFB, pUnkOuter, riid, ppProxy, ppv);
749 IPSFactoryBuffer_Release(pPSFB);
750 return hr;
753 static HRESULT WINAPI PSDispatchFacBuf_CreateStub(IPSFactoryBuffer *iface, REFIID riid, IUnknown *pUnkOuter, IRpcStubBuffer **ppStub)
755 IPSFactoryBuffer *pPSFB;
756 HRESULT hr;
758 if (IsEqualIID(riid, &IID_IDispatch))
759 hr = OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, &IID_IPSFactoryBuffer, (void **)&pPSFB);
760 else
761 hr = TMARSHAL_DllGetClassObject(&CLSID_PSOAInterface, &IID_IPSFactoryBuffer, (void **)&pPSFB);
763 if (FAILED(hr)) return hr;
765 hr = IPSFactoryBuffer_CreateStub(pPSFB, riid, pUnkOuter, ppStub);
767 IPSFactoryBuffer_Release(pPSFB);
768 return hr;
771 static const IPSFactoryBufferVtbl PSDispatchFacBuf_Vtbl =
773 PSDispatchFacBuf_QueryInterface,
774 PSDispatchFacBuf_AddRef,
775 PSDispatchFacBuf_Release,
776 PSDispatchFacBuf_CreateProxy,
777 PSDispatchFacBuf_CreateStub
780 /* This is the whole PSFactoryBuffer object, just the vtableptr */
781 static const IPSFactoryBufferVtbl *pPSDispatchFacBuf = &PSDispatchFacBuf_Vtbl;
783 /***********************************************************************
784 * DllGetClassObject (OLEAUT32.@)
786 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
788 *ppv = NULL;
789 if (IsEqualGUID(rclsid,&CLSID_StdFont)) {
790 if (IsEqualGUID(iid,&IID_IClassFactory)) {
791 _get_STDFONT_CF(ppv);
792 IClassFactory_AddRef((IClassFactory*)*ppv);
793 return S_OK;
796 if (IsEqualGUID(rclsid,&CLSID_StdPicture)) {
797 if (IsEqualGUID(iid,&IID_IClassFactory)) {
798 _get_STDPIC_CF(ppv);
799 IClassFactory_AddRef((IClassFactory*)*ppv);
800 return S_OK;
803 if (IsEqualCLSID(rclsid, &CLSID_PSDispatch) && IsEqualIID(iid, &IID_IPSFactoryBuffer)) {
804 *ppv = &pPSDispatchFacBuf;
805 IPSFactoryBuffer_AddRef((IPSFactoryBuffer *)*ppv);
806 return S_OK;
808 if (IsEqualGUID(rclsid,&CLSID_PSOAInterface)) {
809 if (S_OK==TMARSHAL_DllGetClassObject(rclsid,iid,ppv))
810 return S_OK;
811 /*FALLTHROUGH*/
813 if (IsEqualCLSID(rclsid, &CLSID_PSTypeInfo) ||
814 IsEqualCLSID(rclsid, &CLSID_PSTypeLib) ||
815 IsEqualCLSID(rclsid, &CLSID_PSDispatch) ||
816 IsEqualCLSID(rclsid, &CLSID_PSEnumVariant))
817 return OLEAUTPS_DllGetClassObject(&CLSID_PSFactoryBuffer, iid, ppv);
819 return OLEAUTPS_DllGetClassObject(rclsid, iid, ppv);
822 /***********************************************************************
823 * DllCanUnloadNow (OLEAUT32.@)
825 * Determine if this dll can be unloaded from the callers address space.
827 * PARAMS
828 * None.
830 * RETURNS
831 * Always returns S_FALSE. This dll cannot be unloaded.
833 HRESULT WINAPI DllCanUnloadNow(void)
835 return S_FALSE;
838 /*****************************************************************************
839 * DllMain [OLEAUT32.@]
841 BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
843 return OLEAUTPS_DllMain( hInstDll, fdwReason, lpvReserved );
846 /***********************************************************************
847 * DllRegisterServer (OLEAUT32.@)
849 HRESULT WINAPI DllRegisterServer(void)
851 return OLEAUTPS_DllRegisterServer();
854 /***********************************************************************
855 * DllUnregisterServer (OLEAUT32.@)
857 HRESULT WINAPI DllUnregisterServer(void)
859 return OLEAUTPS_DllUnregisterServer();
862 /***********************************************************************
863 * OleIconToCursor (OLEAUT32.415)
865 HCURSOR WINAPI OleIconToCursor( HINSTANCE hinstExe, HICON hIcon)
867 FIXME("(%p,%p), partially implemented.\n",hinstExe,hIcon);
868 /* FIXME: make a extended conversation from HICON to HCURSOR */
869 return CopyCursor(hIcon);