2 * Copyright 2012 Stefan Leichter
3 * Copyright 2012 Jacek Caban for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define ATLVer1Size FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer)
26 HINSTANCE atl_instance
;
28 typedef unsigned char cpp_bool
;
30 static inline void *heap_alloc(size_t len
)
32 return HeapAlloc(GetProcessHeap(), 0, len
);
35 static inline BOOL
heap_free(void *mem
)
37 return HeapFree(GetProcessHeap(), 0, mem
);
40 static ICatRegister
*catreg
;
42 /***********************************************************************
43 * AtlAdvise [atl100.@]
45 HRESULT WINAPI
AtlAdvise(IUnknown
*pUnkCP
, IUnknown
*pUnk
, const IID
*iid
, DWORD
*pdw
)
47 IConnectionPointContainer
*container
;
51 TRACE("%p %p %p %p\n", pUnkCP
, pUnk
, iid
, pdw
);
56 hres
= IUnknown_QueryInterface(pUnkCP
, &IID_IConnectionPointContainer
, (void**)&container
);
60 hres
= IConnectionPointContainer_FindConnectionPoint(container
, iid
, &cp
);
61 IConnectionPointContainer_Release(container
);
65 hres
= IConnectionPoint_Advise(cp
, pUnk
, pdw
);
66 IConnectionPoint_Release(cp
);
70 /***********************************************************************
71 * AtlUnadvise [atl100.@]
73 HRESULT WINAPI
AtlUnadvise(IUnknown
*pUnkCP
, const IID
*iid
, DWORD dw
)
75 IConnectionPointContainer
*container
;
79 TRACE("%p %p %d\n", pUnkCP
, iid
, dw
);
84 hres
= IUnknown_QueryInterface(pUnkCP
, &IID_IConnectionPointContainer
, (void**)&container
);
88 hres
= IConnectionPointContainer_FindConnectionPoint(container
, iid
, &cp
);
89 IConnectionPointContainer_Release(container
);
93 hres
= IConnectionPoint_Unadvise(cp
, dw
);
94 IConnectionPoint_Release(cp
);
98 /***********************************************************************
99 * AtlFreeMarshalStream [atl100.@]
101 HRESULT WINAPI
AtlFreeMarshalStream(IStream
*stm
)
107 /***********************************************************************
108 * AtlMarshalPtrInProc [atl100.@]
110 HRESULT WINAPI
AtlMarshalPtrInProc(IUnknown
*pUnk
, const IID
*iid
, IStream
**pstm
)
112 FIXME("%p %p %p\n", pUnk
, iid
, pstm
);
116 /***********************************************************************
117 * AtlUnmarshalPtr [atl100.@]
119 HRESULT WINAPI
AtlUnmarshalPtr(IStream
*stm
, const IID
*iid
, IUnknown
**ppUnk
)
121 FIXME("%p %p %p\n", stm
, iid
, ppUnk
);
125 /***********************************************************************
126 * AtlCreateTargetDC [atl100.@]
128 HDC WINAPI
AtlCreateTargetDC( HDC hdc
, DVTARGETDEVICE
*dv
)
130 static const WCHAR displayW
[] = {'d','i','s','p','l','a','y',0};
131 const WCHAR
*driver
= NULL
, *device
= NULL
, *port
= NULL
;
132 DEVMODEW
*devmode
= NULL
;
134 TRACE( "(%p, %p)\n", hdc
, dv
);
138 if (dv
->tdDriverNameOffset
) driver
= (WCHAR
*)((char *)dv
+ dv
->tdDriverNameOffset
);
139 if (dv
->tdDeviceNameOffset
) device
= (WCHAR
*)((char *)dv
+ dv
->tdDeviceNameOffset
);
140 if (dv
->tdPortNameOffset
) port
= (WCHAR
*)((char *)dv
+ dv
->tdPortNameOffset
);
141 if (dv
->tdExtDevmodeOffset
) devmode
= (DEVMODEW
*)((char *)dv
+ dv
->tdExtDevmodeOffset
);
148 return CreateDCW( driver
, device
, port
, devmode
);
151 /***********************************************************************
152 * AtlHiMetricToPixel [atl100.@]
154 void WINAPI
AtlHiMetricToPixel(const SIZEL
* lpHiMetric
, SIZEL
* lpPix
)
156 HDC dc
= GetDC(NULL
);
157 lpPix
->cx
= lpHiMetric
->cx
* GetDeviceCaps( dc
, LOGPIXELSX
) / 100;
158 lpPix
->cy
= lpHiMetric
->cy
* GetDeviceCaps( dc
, LOGPIXELSY
) / 100;
159 ReleaseDC( NULL
, dc
);
162 /***********************************************************************
163 * AtlPixelToHiMetric [atl100.@]
165 void WINAPI
AtlPixelToHiMetric(const SIZEL
* lpPix
, SIZEL
* lpHiMetric
)
167 HDC dc
= GetDC(NULL
);
168 lpHiMetric
->cx
= 100 * lpPix
->cx
/ GetDeviceCaps( dc
, LOGPIXELSX
);
169 lpHiMetric
->cy
= 100 * lpPix
->cy
/ GetDeviceCaps( dc
, LOGPIXELSY
);
170 ReleaseDC( NULL
, dc
);
173 /***********************************************************************
174 * AtlComPtrAssign [atl100.@]
176 IUnknown
* WINAPI
AtlComPtrAssign(IUnknown
** pp
, IUnknown
*p
)
178 TRACE("(%p %p)\n", pp
, p
);
180 if (p
) IUnknown_AddRef(p
);
181 if (*pp
) IUnknown_Release(*pp
);
186 /***********************************************************************
187 * AtlComQIPtrAssign [atl100.@]
189 IUnknown
* WINAPI
AtlComQIPtrAssign(IUnknown
** pp
, IUnknown
*p
, REFIID riid
)
191 IUnknown
*new_p
= NULL
;
193 TRACE("(%p %p %s)\n", pp
, p
, debugstr_guid(riid
));
195 if (p
) IUnknown_QueryInterface(p
, riid
, (void **)&new_p
);
196 if (*pp
) IUnknown_Release(*pp
);
201 /***********************************************************************
202 * AtlInternalQueryInterface [atl100.@]
204 HRESULT WINAPI
AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY
* pEntries
, REFIID iid
, void** ppvObject
)
207 HRESULT rc
= E_NOINTERFACE
;
208 TRACE("(%p, %p, %s, %p)\n",this, pEntries
, debugstr_guid(iid
), ppvObject
);
210 if (IsEqualGUID(iid
,&IID_IUnknown
))
212 TRACE("Returning IUnknown\n");
213 *ppvObject
= ((LPSTR
)this+pEntries
[0].dw
);
214 IUnknown_AddRef((IUnknown
*)*ppvObject
);
218 while (pEntries
[i
].pFunc
!= 0)
220 TRACE("Trying entry %i (%s %i %p)\n",i
,debugstr_guid(pEntries
[i
].piid
),
221 pEntries
[i
].dw
, pEntries
[i
].pFunc
);
223 if (!pEntries
[i
].piid
|| IsEqualGUID(iid
,pEntries
[i
].piid
))
226 if (pEntries
[i
].pFunc
== (_ATL_CREATORARGFUNC
*)1)
229 *ppvObject
= ((LPSTR
)this+pEntries
[i
].dw
);
230 IUnknown_AddRef((IUnknown
*)*ppvObject
);
236 rc
= pEntries
[i
].pFunc(this, iid
, ppvObject
, pEntries
[i
].dw
);
237 if(rc
==S_OK
|| pEntries
[i
].piid
)
243 TRACE("Done returning (0x%x)\n",rc
);
247 /* FIXME: should be in a header file */
248 typedef struct ATL_PROPMAP_ENTRY
252 const CLSID
* pclsidPropPage
;
253 const IID
* piidDispatch
;
259 /***********************************************************************
260 * AtlIPersistStreamInit_Load [atl100.@]
262 HRESULT WINAPI
AtlIPersistStreamInit_Load( LPSTREAM pStm
, ATL_PROPMAP_ENTRY
*pMap
,
263 void *pThis
, IUnknown
*pUnk
)
265 FIXME("(%p, %p, %p, %p)\n", pStm
, pMap
, pThis
, pUnk
);
270 /***********************************************************************
271 * AtlIPersistStreamInit_Save [atl100.@]
273 HRESULT WINAPI
AtlIPersistStreamInit_Save(LPSTREAM pStm
, BOOL fClearDirty
,
274 ATL_PROPMAP_ENTRY
*pMap
, void *pThis
,
277 FIXME("(%p, %d, %p, %p, %p)\n", pStm
, fClearDirty
, pMap
, pThis
, pUnk
);
282 /***********************************************************************
283 * AtlIPersistPropertyBag_Load [atl100.@]
285 HRESULT WINAPI
AtlIPersistPropertyBag_Load(LPPROPERTYBAG pPropBag
, LPERRORLOG pErrorLog
,
286 ATL_PROPMAP_ENTRY
*pMap
, void *pThis
,
289 FIXME("(%p, %p, %p, %p, %p)\n", pPropBag
, pErrorLog
, pMap
, pThis
, pUnk
);
294 /***********************************************************************
295 * AtlModuleAddTermFunc [atl100.@]
297 HRESULT WINAPI
AtlModuleAddTermFunc(_ATL_MODULE
*pM
, _ATL_TERMFUNC
*pFunc
, DWORD_PTR dw
)
299 _ATL_TERMFUNC_ELEM
*termfunc_elem
;
301 TRACE("version %04x (%p %p %ld)\n", _ATL_VER
, pM
, pFunc
, dw
);
303 if (_ATL_VER
> _ATL_VER_30
|| pM
->cbSize
> ATLVer1Size
) {
304 termfunc_elem
= HeapAlloc(GetProcessHeap(), 0, sizeof(_ATL_TERMFUNC_ELEM
));
305 termfunc_elem
->pFunc
= pFunc
;
306 termfunc_elem
->dw
= dw
;
307 termfunc_elem
->pNext
= pM
->m_pTermFuncs
;
309 pM
->m_pTermFuncs
= termfunc_elem
;
315 #if _ATL_VER > _ATL_VER_30
317 /***********************************************************************
318 * AtlCallTermFunc [atl100.@]
320 void WINAPI
AtlCallTermFunc(_ATL_MODULE
*pM
)
322 _ATL_TERMFUNC_ELEM
*iter
= pM
->m_pTermFuncs
, *tmp
;
327 iter
->pFunc(iter
->dw
);
330 HeapFree(GetProcessHeap(), 0, tmp
);
333 pM
->m_pTermFuncs
= NULL
;
338 /***********************************************************************
339 * AtlLoadTypeLib [atl100.56]
341 HRESULT WINAPI
AtlLoadTypeLib(HINSTANCE inst
, LPCOLESTR lpszIndex
,
342 BSTR
*pbstrPath
, ITypeLib
**ppTypeLib
)
344 size_t path_len
, index_len
;
345 ITypeLib
*typelib
= NULL
;
349 static const WCHAR tlb_extW
[] = {'.','t','l','b',0};
351 TRACE("(%p %s %p %p)\n", inst
, debugstr_w(lpszIndex
), pbstrPath
, ppTypeLib
);
353 index_len
= lpszIndex
? strlenW(lpszIndex
) : 0;
354 path
= heap_alloc((MAX_PATH
+index_len
)*sizeof(WCHAR
) + sizeof(tlb_extW
));
356 return E_OUTOFMEMORY
;
358 path_len
= GetModuleFileNameW(inst
, path
, MAX_PATH
);
361 return HRESULT_FROM_WIN32(GetLastError());
365 memcpy(path
+path_len
, lpszIndex
, (index_len
+1)*sizeof(WCHAR
));
367 hres
= LoadTypeLib(path
, &typelib
);
371 for(ptr
= path
+path_len
-1; ptr
> path
&& *ptr
!= '\\' && *ptr
!= '.'; ptr
--);
374 memcpy(ptr
, tlb_extW
, sizeof(tlb_extW
));
375 hres
= LoadTypeLib(path
, &typelib
);
378 if(SUCCEEDED(hres
)) {
379 *pbstrPath
= SysAllocString(path
);
381 ITypeLib_Release(typelib
);
382 hres
= E_OUTOFMEMORY
;
390 *ppTypeLib
= typelib
;
394 #if _ATL_VER <= _ATL_VER_80
396 /***********************************************************************
397 * AtlRegisterTypeLib [atl80.19]
399 HRESULT WINAPI
AtlRegisterTypeLib(HINSTANCE inst
, const WCHAR
*index
)
405 TRACE("(%p %s)\n", inst
, debugstr_w(index
));
407 hres
= AtlLoadTypeLib(inst
, index
, &path
, &typelib
);
411 hres
= RegisterTypeLib(typelib
, path
, NULL
); /* FIXME: pass help directory */
412 ITypeLib_Release(typelib
);
419 #if _ATL_VER > _ATL_VER_30
421 /***********************************************************************
422 * AtlWinModuleInit [atl100.65]
424 HRESULT WINAPI
AtlWinModuleInit(_ATL_WIN_MODULE
*winmod
)
426 TRACE("(%p)\n", winmod
);
428 if(winmod
->cbSize
!= sizeof(*winmod
))
431 InitializeCriticalSection(&winmod
->m_csWindowCreate
);
432 winmod
->m_pCreateWndList
= NULL
;
436 /***********************************************************************
437 * AtlWinModuleAddCreateWndData [atl100.43]
439 void WINAPI
AtlWinModuleAddCreateWndData(_ATL_WIN_MODULE
*pM
, _AtlCreateWndData
*pData
, void *pvObject
)
441 TRACE("(%p, %p, %p)\n", pM
, pData
, pvObject
);
443 pData
->m_pThis
= pvObject
;
444 pData
->m_dwThreadID
= GetCurrentThreadId();
446 EnterCriticalSection(&pM
->m_csWindowCreate
);
447 pData
->m_pNext
= pM
->m_pCreateWndList
;
448 pM
->m_pCreateWndList
= pData
;
449 LeaveCriticalSection(&pM
->m_csWindowCreate
);
452 /***********************************************************************
453 * AtlWinModuleExtractCreateWndData [atl100.44]
455 void* WINAPI
AtlWinModuleExtractCreateWndData(_ATL_WIN_MODULE
*winmod
)
457 _AtlCreateWndData
*iter
, *prev
= NULL
;
460 TRACE("(%p)\n", winmod
);
462 thread_id
= GetCurrentThreadId();
464 EnterCriticalSection(&winmod
->m_csWindowCreate
);
466 for(iter
= winmod
->m_pCreateWndList
; iter
&& iter
->m_dwThreadID
!= thread_id
; iter
= iter
->m_pNext
)
470 prev
->m_pNext
= iter
->m_pNext
;
472 winmod
->m_pCreateWndList
= iter
->m_pNext
;
475 LeaveCriticalSection(&winmod
->m_csWindowCreate
);
477 return iter
? iter
->m_pThis
: NULL
;
480 /***********************************************************************
481 * AtlComModuleGetClassObject [atl100.15]
483 HRESULT WINAPI
AtlComModuleGetClassObject(_ATL_COM_MODULE
*pm
, REFCLSID rclsid
, REFIID riid
, void **ppv
)
485 _ATL_OBJMAP_ENTRY
**iter
;
488 TRACE("(%p %s %s %p)\n", pm
, debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
493 for(iter
= pm
->m_ppAutoObjMapFirst
; iter
< pm
->m_ppAutoObjMapLast
; iter
++) {
494 if(IsEqualCLSID((*iter
)->pclsid
, rclsid
) && (*iter
)->pfnGetClassObject
) {
496 hres
= (*iter
)->pfnGetClassObject((*iter
)->pfnCreateInstance
, &IID_IUnknown
, (void**)&(*iter
)->pCF
);
498 hres
= IUnknown_QueryInterface((*iter
)->pCF
, riid
, ppv
);
499 TRACE("returning %p (%08x)\n", *ppv
, hres
);
504 WARN("Class %s not found\n", debugstr_guid(rclsid
));
505 return CLASS_E_CLASSNOTAVAILABLE
;
508 /***********************************************************************
509 * AtlComModuleRegisterClassObjects [atl100.17]
511 HRESULT WINAPI
AtlComModuleRegisterClassObjects(_ATL_COM_MODULE
*module
, DWORD context
, DWORD flags
)
513 _ATL_OBJMAP_ENTRY
**iter
;
517 TRACE("(%p %x %x)\n", module
, context
, flags
);
522 for(iter
= module
->m_ppAutoObjMapFirst
; iter
< module
->m_ppAutoObjMapLast
; iter
++) {
523 if(!(*iter
)->pfnGetClassObject
)
526 hres
= (*iter
)->pfnGetClassObject((*iter
)->pfnCreateInstance
, &IID_IUnknown
, (void**)&unk
);
530 hres
= CoRegisterClassObject((*iter
)->pclsid
, unk
, context
, flags
, &(*iter
)->dwRegister
);
531 IUnknown_Release(unk
);
539 /***********************************************************************
540 * AtlComModuleRevokeClassObjects [atl100.20]
542 HRESULT WINAPI
AtlComModuleRevokeClassObjects(_ATL_COM_MODULE
*module
)
544 _ATL_OBJMAP_ENTRY
**iter
;
547 TRACE("(%p)\n", module
);
552 for(iter
= module
->m_ppAutoObjMapFirst
; iter
< module
->m_ppAutoObjMapLast
; iter
++) {
553 hres
= CoRevokeClassObject((*iter
)->dwRegister
);
561 /***********************************************************************
562 * AtlComModuleUnregisterServer [atl100.22]
564 HRESULT WINAPI
AtlComModuleUnregisterServer(_ATL_COM_MODULE
*mod
, BOOL bRegTypeLib
, const CLSID
*clsid
)
566 const struct _ATL_CATMAP_ENTRY
*catmap
;
567 _ATL_OBJMAP_ENTRY
**iter
;
570 TRACE("(%p %x %s)\n", mod
, bRegTypeLib
, debugstr_guid(clsid
));
572 for(iter
= mod
->m_ppAutoObjMapFirst
; iter
< mod
->m_ppAutoObjMapLast
; iter
++) {
573 if(!*iter
|| (clsid
&& !IsEqualCLSID((*iter
)->pclsid
, clsid
)))
576 TRACE("Unregistering clsid %s\n", debugstr_guid((*iter
)->pclsid
));
578 catmap
= (*iter
)->pfnGetCategoryMap();
580 hres
= AtlRegisterClassCategoriesHelper((*iter
)->pclsid
, catmap
, FALSE
);
585 hres
= (*iter
)->pfnUpdateRegistry(FALSE
);
595 hres
= AtlLoadTypeLib(mod
->m_hInstTypeLib
, NULL
, &path
, &typelib
);
600 hres
= ITypeLib_GetLibAttr(typelib
, &attr
);
601 if(SUCCEEDED(hres
)) {
602 hres
= UnRegisterTypeLib(&attr
->guid
, attr
->wMajorVerNum
, attr
->wMinorVerNum
, attr
->lcid
, attr
->syskind
);
603 ITypeLib_ReleaseTLibAttr(typelib
, attr
);
605 ITypeLib_Release(typelib
);
615 /***********************************************************************
616 * AtlRegisterClassCategoriesHelper [atl100.49]
618 HRESULT WINAPI
AtlRegisterClassCategoriesHelper(REFCLSID clsid
, const struct _ATL_CATMAP_ENTRY
*catmap
, BOOL reg
)
620 const struct _ATL_CATMAP_ENTRY
*iter
;
623 TRACE("(%s %p %x)\n", debugstr_guid(clsid
), catmap
, reg
);
629 ICatRegister
*new_catreg
;
631 hres
= CoCreateInstance(&CLSID_StdComponentCategoriesMgr
, NULL
, CLSCTX_INPROC_SERVER
,
632 &IID_ICatRegister
, (void**)&new_catreg
);
636 if(InterlockedCompareExchangePointer((void**)&catreg
, new_catreg
, NULL
))
637 ICatRegister_Release(new_catreg
);
640 for(iter
= catmap
; iter
->iType
!= _ATL_CATMAP_ENTRY_END
; iter
++) {
641 CATID catid
= *iter
->pcatid
; /* For stupid lack of const in ICatRegister declaration. */
643 if(iter
->iType
== _ATL_CATMAP_ENTRY_IMPLEMENTED
) {
645 hres
= ICatRegister_RegisterClassImplCategories(catreg
, clsid
, 1, &catid
);
647 hres
= ICatRegister_UnRegisterClassImplCategories(catreg
, clsid
, 1, &catid
);
650 hres
= ICatRegister_RegisterClassReqCategories(catreg
, clsid
, 1, &catid
);
652 hres
= ICatRegister_UnRegisterClassReqCategories(catreg
, clsid
, 1, &catid
);
659 WCHAR reg_path
[256] = {'C','L','S','I','D','\\'}, *ptr
= reg_path
+6;
661 static const WCHAR implemented_catW
[] =
662 {'I','m','p','l','e','m','e','n','t','e','d',' ','C','a','t','e','g','o','r','i','e','s',0};
663 static const WCHAR required_catW
[] =
664 {'R','e','q','u','i','r','e','d',' ','C','a','t','e','g','o','r','i','e','s',0};
666 ptr
+= StringFromGUID2(clsid
, ptr
, 64)-1;
669 memcpy(ptr
, implemented_catW
, sizeof(implemented_catW
));
670 RegDeleteKeyW(HKEY_CLASSES_ROOT
, reg_path
);
672 memcpy(ptr
, required_catW
, sizeof(required_catW
));
673 RegDeleteKeyW(HKEY_CLASSES_ROOT
, reg_path
);
679 /***********************************************************************
680 * AtlWaitWithMessageLoop [atl100.24]
682 BOOL WINAPI
AtlWaitWithMessageLoop(HANDLE handle
)
687 TRACE("(%p)\n", handle
);
690 res
= MsgWaitForMultipleObjects(1, &handle
, FALSE
, INFINITE
, QS_ALLINPUT
);
694 case WAIT_OBJECT_0
+1:
695 if(GetMessageW(&msg
, NULL
, 0, 0) < 0)
698 TranslateMessage(&msg
);
699 DispatchMessageW(&msg
);
707 static HRESULT
get_default_source(ITypeLib
*typelib
, const CLSID
*clsid
, IID
*iid
)
709 ITypeInfo
*typeinfo
, *src_typeinfo
= NULL
;
715 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, clsid
, &typeinfo
);
719 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &attr
);
721 ITypeInfo_Release(typeinfo
);
725 for(i
=0; i
< attr
->cImplTypes
; i
++) {
726 hres
= ITypeInfo_GetImplTypeFlags(typeinfo
, i
, &type_flags
);
727 if(SUCCEEDED(hres
) && type_flags
== (IMPLTYPEFLAG_FSOURCE
|IMPLTYPEFLAG_FDEFAULT
)) {
730 hres
= ITypeInfo_GetRefTypeOfImplType(typeinfo
, i
, &ref
);
732 hres
= ITypeInfo_GetRefTypeInfo(typeinfo
, ref
, &src_typeinfo
);
737 ITypeInfo_ReleaseTypeAttr(typeinfo
, attr
);
738 ITypeInfo_Release(typeinfo
);
747 hres
= ITypeInfo_GetTypeAttr(src_typeinfo
, &attr
);
748 if(SUCCEEDED(hres
)) {
750 ITypeInfo_ReleaseTypeAttr(src_typeinfo
, attr
);
752 ITypeInfo_Release(src_typeinfo
);
756 /***********************************************************************
757 * AtlGetObjectSourceInterface [atl100.54]
759 HRESULT WINAPI
AtlGetObjectSourceInterface(IUnknown
*unk
, GUID
*libid
, IID
*iid
, unsigned short *major
, unsigned short *minor
)
761 IProvideClassInfo2
*classinfo
;
768 TRACE("(%p %p %p %p %p)\n", unk
, libid
, iid
, major
, minor
);
770 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp
);
774 hres
= IDispatch_GetTypeInfo(disp
, 0, 0, &typeinfo
);
775 IDispatch_Release(disp
);
779 hres
= ITypeInfo_GetContainingTypeLib(typeinfo
, &typelib
, 0);
780 ITypeInfo_Release(typeinfo
);
781 if(SUCCEEDED(hres
)) {
784 hres
= ITypeLib_GetLibAttr(typelib
, &attr
);
785 if(SUCCEEDED(hres
)) {
787 *major
= attr
->wMajorVerNum
;
788 *minor
= attr
->wMinorVerNum
;
789 ITypeLib_ReleaseTLibAttr(typelib
, attr
);
791 ITypeLib_Release(typelib
);
797 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo2
, (void**)&classinfo
);
798 if(SUCCEEDED(hres
)) {
799 hres
= IProvideClassInfo2_GetGUID(classinfo
, GUIDKIND_DEFAULT_SOURCE_DISP_IID
, iid
);
800 IProvideClassInfo2_Release(classinfo
);
801 ITypeLib_Release(typelib
);
805 hres
= IUnknown_QueryInterface(unk
, &IID_IPersist
, (void**)&persist
);
806 if(SUCCEEDED(hres
)) {
809 hres
= IPersist_GetClassID(persist
, &clsid
);
811 hres
= get_default_source(typelib
, &clsid
, iid
);
812 IPersist_Release(persist
);
818 #if _ATL_VER >= _ATL_VER90
820 /***********************************************************************
821 * AtlSetPerUserRegistration [atl100.67]
823 HRESULT WINAPI
AtlSetPerUserRegistration(cpp_bool bEnable
)
825 FIXME("stub: bEnable: %d\n", bEnable
);
829 /***********************************************************************
830 * AtlGetPerUserRegistration [atl100.68]
832 HRESULT WINAPI
AtlGetPerUserRegistration(cpp_bool
*pbEnabled
)
834 FIXME("stub: returning false\n");
841 /***********************************************************************
842 * AtlGetVersion [atl100.@]
844 DWORD WINAPI
AtlGetVersion(void *pReserved
)
846 TRACE("version %04x (%p)\n", _ATL_VER
, pReserved
);
850 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
852 TRACE("(0x%p, %d, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
855 case DLL_PROCESS_ATTACH
:
856 atl_instance
= hinstDLL
;
857 DisableThreadLibraryCalls(hinstDLL
);
859 case DLL_PROCESS_DETACH
:
860 if (lpvReserved
) break;
862 ICatRegister_Release(catreg
);