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
25 #include "wine/debug.h"
26 #include "wine/unicode.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(atl
);
30 #define ATLVer1Size FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer)
32 HINSTANCE atl_instance
;
34 typedef unsigned char cpp_bool
;
36 static inline void *heap_alloc(size_t len
)
38 return HeapAlloc(GetProcessHeap(), 0, len
);
41 static inline BOOL
heap_free(void *mem
)
43 return HeapFree(GetProcessHeap(), 0, mem
);
46 static ICatRegister
*catreg
;
48 /***********************************************************************
49 * AtlAdvise [atl100.@]
51 HRESULT WINAPI
AtlAdvise(IUnknown
*pUnkCP
, IUnknown
*pUnk
, const IID
*iid
, DWORD
*pdw
)
53 IConnectionPointContainer
*container
;
57 TRACE("%p %p %p %p\n", pUnkCP
, pUnk
, iid
, pdw
);
62 hres
= IUnknown_QueryInterface(pUnkCP
, &IID_IConnectionPointContainer
, (void**)&container
);
66 hres
= IConnectionPointContainer_FindConnectionPoint(container
, iid
, &cp
);
67 IConnectionPointContainer_Release(container
);
71 hres
= IConnectionPoint_Advise(cp
, pUnk
, pdw
);
72 IConnectionPoint_Release(cp
);
76 /***********************************************************************
77 * AtlUnadvise [atl100.@]
79 HRESULT WINAPI
AtlUnadvise(IUnknown
*pUnkCP
, const IID
*iid
, DWORD dw
)
81 IConnectionPointContainer
*container
;
85 TRACE("%p %p %d\n", pUnkCP
, iid
, dw
);
90 hres
= IUnknown_QueryInterface(pUnkCP
, &IID_IConnectionPointContainer
, (void**)&container
);
94 hres
= IConnectionPointContainer_FindConnectionPoint(container
, iid
, &cp
);
95 IConnectionPointContainer_Release(container
);
99 hres
= IConnectionPoint_Unadvise(cp
, dw
);
100 IConnectionPoint_Release(cp
);
104 /***********************************************************************
105 * AtlFreeMarshalStream [atl100.@]
107 HRESULT WINAPI
AtlFreeMarshalStream(IStream
*stm
)
113 /***********************************************************************
114 * AtlMarshalPtrInProc [atl100.@]
116 HRESULT WINAPI
AtlMarshalPtrInProc(IUnknown
*pUnk
, const IID
*iid
, IStream
**pstm
)
118 FIXME("%p %p %p\n", pUnk
, iid
, pstm
);
122 /***********************************************************************
123 * AtlUnmarshalPtr [atl100.@]
125 HRESULT WINAPI
AtlUnmarshalPtr(IStream
*stm
, const IID
*iid
, IUnknown
**ppUnk
)
127 FIXME("%p %p %p\n", stm
, iid
, ppUnk
);
131 /***********************************************************************
132 * AtlCreateTargetDC [atl100.@]
134 HDC WINAPI
AtlCreateTargetDC( HDC hdc
, DVTARGETDEVICE
*dv
)
136 static const WCHAR displayW
[] = {'d','i','s','p','l','a','y',0};
137 const WCHAR
*driver
= NULL
, *device
= NULL
, *port
= NULL
;
138 DEVMODEW
*devmode
= NULL
;
140 TRACE( "(%p, %p)\n", hdc
, dv
);
144 if (dv
->tdDriverNameOffset
) driver
= (WCHAR
*)((char *)dv
+ dv
->tdDriverNameOffset
);
145 if (dv
->tdDeviceNameOffset
) device
= (WCHAR
*)((char *)dv
+ dv
->tdDeviceNameOffset
);
146 if (dv
->tdPortNameOffset
) port
= (WCHAR
*)((char *)dv
+ dv
->tdPortNameOffset
);
147 if (dv
->tdExtDevmodeOffset
) devmode
= (DEVMODEW
*)((char *)dv
+ dv
->tdExtDevmodeOffset
);
154 return CreateDCW( driver
, device
, port
, devmode
);
157 /***********************************************************************
158 * AtlHiMetricToPixel [atl100.@]
160 void WINAPI
AtlHiMetricToPixel(const SIZEL
* lpHiMetric
, SIZEL
* lpPix
)
162 HDC dc
= GetDC(NULL
);
163 lpPix
->cx
= lpHiMetric
->cx
* GetDeviceCaps( dc
, LOGPIXELSX
) / 100;
164 lpPix
->cy
= lpHiMetric
->cy
* GetDeviceCaps( dc
, LOGPIXELSY
) / 100;
165 ReleaseDC( NULL
, dc
);
168 /***********************************************************************
169 * AtlPixelToHiMetric [atl100.@]
171 void WINAPI
AtlPixelToHiMetric(const SIZEL
* lpPix
, SIZEL
* lpHiMetric
)
173 HDC dc
= GetDC(NULL
);
174 lpHiMetric
->cx
= 100 * lpPix
->cx
/ GetDeviceCaps( dc
, LOGPIXELSX
);
175 lpHiMetric
->cy
= 100 * lpPix
->cy
/ GetDeviceCaps( dc
, LOGPIXELSY
);
176 ReleaseDC( NULL
, dc
);
179 /***********************************************************************
180 * AtlComPtrAssign [atl100.@]
182 IUnknown
* WINAPI
AtlComPtrAssign(IUnknown
** pp
, IUnknown
*p
)
184 TRACE("(%p %p)\n", pp
, p
);
186 if (p
) IUnknown_AddRef(p
);
187 if (*pp
) IUnknown_Release(*pp
);
192 /***********************************************************************
193 * AtlComQIPtrAssign [atl100.@]
195 IUnknown
* WINAPI
AtlComQIPtrAssign(IUnknown
** pp
, IUnknown
*p
, REFIID riid
)
197 IUnknown
*new_p
= NULL
;
199 TRACE("(%p %p %s)\n", pp
, p
, debugstr_guid(riid
));
201 if (p
) IUnknown_QueryInterface(p
, riid
, (void **)&new_p
);
202 if (*pp
) IUnknown_Release(*pp
);
207 /***********************************************************************
208 * AtlInternalQueryInterface [atl100.@]
210 HRESULT WINAPI
AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY
* pEntries
, REFIID iid
, void** ppvObject
)
213 HRESULT rc
= E_NOINTERFACE
;
214 TRACE("(%p, %p, %s, %p)\n",this, pEntries
, debugstr_guid(iid
), ppvObject
);
216 if (IsEqualGUID(iid
,&IID_IUnknown
))
218 TRACE("Returning IUnknown\n");
219 *ppvObject
= ((LPSTR
)this+pEntries
[0].dw
);
220 IUnknown_AddRef((IUnknown
*)*ppvObject
);
224 while (pEntries
[i
].pFunc
!= 0)
226 TRACE("Trying entry %i (%s %i %p)\n",i
,debugstr_guid(pEntries
[i
].piid
),
227 pEntries
[i
].dw
, pEntries
[i
].pFunc
);
229 if (!pEntries
[i
].piid
|| IsEqualGUID(iid
,pEntries
[i
].piid
))
232 if (pEntries
[i
].pFunc
== (_ATL_CREATORARGFUNC
*)1)
235 *ppvObject
= ((LPSTR
)this+pEntries
[i
].dw
);
236 IUnknown_AddRef((IUnknown
*)*ppvObject
);
242 rc
= pEntries
[i
].pFunc(this, iid
, ppvObject
, pEntries
[i
].dw
);
243 if(rc
==S_OK
|| pEntries
[i
].piid
)
249 TRACE("Done returning (0x%x)\n",rc
);
253 /***********************************************************************
254 * AtlIPersistStreamInit_Load [atl100.@]
256 HRESULT WINAPI
AtlIPersistStreamInit_Load( LPSTREAM pStm
, ATL_PROPMAP_ENTRY
*pMap
,
257 void *pThis
, IUnknown
*pUnk
)
259 FIXME("(%p, %p, %p, %p)\n", pStm
, pMap
, pThis
, pUnk
);
264 /***********************************************************************
265 * AtlIPersistStreamInit_Save [atl100.@]
267 HRESULT WINAPI
AtlIPersistStreamInit_Save(LPSTREAM pStm
, BOOL fClearDirty
,
268 ATL_PROPMAP_ENTRY
*pMap
, void *pThis
,
271 FIXME("(%p, %d, %p, %p, %p)\n", pStm
, fClearDirty
, pMap
, pThis
, pUnk
);
276 /***********************************************************************
277 * AtlIPersistPropertyBag_Load [atl100.@]
279 HRESULT WINAPI
AtlIPersistPropertyBag_Load(LPPROPERTYBAG pPropBag
, LPERRORLOG pErrorLog
,
280 ATL_PROPMAP_ENTRY
*pMap
, void *pThis
,
283 FIXME("(%p, %p, %p, %p, %p)\n", pPropBag
, pErrorLog
, pMap
, pThis
, pUnk
);
288 /***********************************************************************
289 * AtlModuleAddTermFunc [atl100.@]
291 HRESULT WINAPI
AtlModuleAddTermFunc(_ATL_MODULE
*pM
, _ATL_TERMFUNC
*pFunc
, DWORD_PTR dw
)
293 _ATL_TERMFUNC_ELEM
*termfunc_elem
;
295 TRACE("version %04x (%p %p %ld)\n", _ATL_VER
, pM
, pFunc
, dw
);
297 if (_ATL_VER
> _ATL_VER_30
|| pM
->cbSize
> ATLVer1Size
) {
298 termfunc_elem
= HeapAlloc(GetProcessHeap(), 0, sizeof(_ATL_TERMFUNC_ELEM
));
299 termfunc_elem
->pFunc
= pFunc
;
300 termfunc_elem
->dw
= dw
;
301 termfunc_elem
->pNext
= pM
->m_pTermFuncs
;
303 pM
->m_pTermFuncs
= termfunc_elem
;
309 #if _ATL_VER > _ATL_VER_30
311 /***********************************************************************
312 * AtlCallTermFunc [atl100.@]
314 void WINAPI
AtlCallTermFunc(_ATL_MODULE
*pM
)
316 _ATL_TERMFUNC_ELEM
*iter
= pM
->m_pTermFuncs
, *tmp
;
321 iter
->pFunc(iter
->dw
);
324 HeapFree(GetProcessHeap(), 0, tmp
);
327 pM
->m_pTermFuncs
= NULL
;
332 /***********************************************************************
333 * AtlLoadTypeLib [atl100.56]
335 HRESULT WINAPI
AtlLoadTypeLib(HINSTANCE inst
, LPCOLESTR lpszIndex
,
336 BSTR
*pbstrPath
, ITypeLib
**ppTypeLib
)
338 size_t path_len
, index_len
;
339 ITypeLib
*typelib
= NULL
;
343 static const WCHAR tlb_extW
[] = {'.','t','l','b',0};
345 TRACE("(%p %s %p %p)\n", inst
, debugstr_w(lpszIndex
), pbstrPath
, ppTypeLib
);
347 index_len
= lpszIndex
? strlenW(lpszIndex
) : 0;
348 path
= heap_alloc((MAX_PATH
+index_len
)*sizeof(WCHAR
) + sizeof(tlb_extW
));
350 return E_OUTOFMEMORY
;
352 path_len
= GetModuleFileNameW(inst
, path
, MAX_PATH
);
355 return HRESULT_FROM_WIN32(GetLastError());
359 memcpy(path
+path_len
, lpszIndex
, (index_len
+1)*sizeof(WCHAR
));
361 hres
= LoadTypeLib(path
, &typelib
);
365 for(ptr
= path
+path_len
-1; ptr
> path
&& *ptr
!= '\\' && *ptr
!= '.'; ptr
--);
368 memcpy(ptr
, tlb_extW
, sizeof(tlb_extW
));
369 hres
= LoadTypeLib(path
, &typelib
);
372 if(SUCCEEDED(hres
)) {
373 *pbstrPath
= SysAllocString(path
);
375 ITypeLib_Release(typelib
);
376 hres
= E_OUTOFMEMORY
;
384 *ppTypeLib
= typelib
;
388 #if _ATL_VER <= _ATL_VER_80
390 /***********************************************************************
391 * AtlRegisterTypeLib [atl80.19]
393 HRESULT WINAPI
AtlRegisterTypeLib(HINSTANCE inst
, const WCHAR
*index
)
399 TRACE("(%p %s)\n", inst
, debugstr_w(index
));
401 hres
= AtlLoadTypeLib(inst
, index
, &path
, &typelib
);
405 hres
= RegisterTypeLib(typelib
, path
, NULL
); /* FIXME: pass help directory */
406 ITypeLib_Release(typelib
);
413 #if _ATL_VER > _ATL_VER_30
415 /***********************************************************************
416 * AtlWinModuleInit [atl100.65]
418 HRESULT WINAPI
AtlWinModuleInit(_ATL_WIN_MODULE
*winmod
)
420 TRACE("(%p)\n", winmod
);
422 if(winmod
->cbSize
!= sizeof(*winmod
))
425 InitializeCriticalSection(&winmod
->m_csWindowCreate
);
426 winmod
->m_pCreateWndList
= NULL
;
430 /***********************************************************************
431 * AtlWinModuleAddCreateWndData [atl100.43]
433 void WINAPI
AtlWinModuleAddCreateWndData(_ATL_WIN_MODULE
*pM
, _AtlCreateWndData
*pData
, void *pvObject
)
435 TRACE("(%p, %p, %p)\n", pM
, pData
, pvObject
);
437 pData
->m_pThis
= pvObject
;
438 pData
->m_dwThreadID
= GetCurrentThreadId();
440 EnterCriticalSection(&pM
->m_csWindowCreate
);
441 pData
->m_pNext
= pM
->m_pCreateWndList
;
442 pM
->m_pCreateWndList
= pData
;
443 LeaveCriticalSection(&pM
->m_csWindowCreate
);
446 /***********************************************************************
447 * AtlWinModuleExtractCreateWndData [atl100.44]
449 void* WINAPI
AtlWinModuleExtractCreateWndData(_ATL_WIN_MODULE
*winmod
)
451 _AtlCreateWndData
*iter
, *prev
= NULL
;
454 TRACE("(%p)\n", winmod
);
456 thread_id
= GetCurrentThreadId();
458 EnterCriticalSection(&winmod
->m_csWindowCreate
);
460 for(iter
= winmod
->m_pCreateWndList
; iter
&& iter
->m_dwThreadID
!= thread_id
; iter
= iter
->m_pNext
)
464 prev
->m_pNext
= iter
->m_pNext
;
466 winmod
->m_pCreateWndList
= iter
->m_pNext
;
469 LeaveCriticalSection(&winmod
->m_csWindowCreate
);
471 return iter
? iter
->m_pThis
: NULL
;
474 /***********************************************************************
475 * AtlComModuleGetClassObject [atl100.15]
477 HRESULT WINAPI
AtlComModuleGetClassObject(_ATL_COM_MODULE
*pm
, REFCLSID rclsid
, REFIID riid
, void **ppv
)
479 _ATL_OBJMAP_ENTRY
**iter
;
482 TRACE("(%p %s %s %p)\n", pm
, debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
487 for(iter
= pm
->m_ppAutoObjMapFirst
; iter
< pm
->m_ppAutoObjMapLast
; iter
++) {
488 if(IsEqualCLSID((*iter
)->pclsid
, rclsid
) && (*iter
)->pfnGetClassObject
) {
490 hres
= (*iter
)->pfnGetClassObject((*iter
)->pfnCreateInstance
, &IID_IUnknown
, (void**)&(*iter
)->pCF
);
492 hres
= IUnknown_QueryInterface((*iter
)->pCF
, riid
, ppv
);
493 TRACE("returning %p (%08x)\n", *ppv
, hres
);
498 WARN("Class %s not found\n", debugstr_guid(rclsid
));
499 return CLASS_E_CLASSNOTAVAILABLE
;
502 /***********************************************************************
503 * AtlComModuleRegisterClassObjects [atl100.17]
505 HRESULT WINAPI
AtlComModuleRegisterClassObjects(_ATL_COM_MODULE
*module
, DWORD context
, DWORD flags
)
507 _ATL_OBJMAP_ENTRY
**iter
;
511 TRACE("(%p %x %x)\n", module
, context
, flags
);
516 for(iter
= module
->m_ppAutoObjMapFirst
; iter
< module
->m_ppAutoObjMapLast
; iter
++) {
517 if(!(*iter
)->pfnGetClassObject
)
520 hres
= (*iter
)->pfnGetClassObject((*iter
)->pfnCreateInstance
, &IID_IUnknown
, (void**)&unk
);
524 hres
= CoRegisterClassObject((*iter
)->pclsid
, unk
, context
, flags
, &(*iter
)->dwRegister
);
525 IUnknown_Release(unk
);
533 /***********************************************************************
534 * AtlComModuleRevokeClassObjects [atl100.20]
536 HRESULT WINAPI
AtlComModuleRevokeClassObjects(_ATL_COM_MODULE
*module
)
538 _ATL_OBJMAP_ENTRY
**iter
;
541 TRACE("(%p)\n", module
);
546 for(iter
= module
->m_ppAutoObjMapFirst
; iter
< module
->m_ppAutoObjMapLast
; iter
++) {
547 hres
= CoRevokeClassObject((*iter
)->dwRegister
);
555 /***********************************************************************
556 * AtlComModuleUnregisterServer [atl100.22]
558 HRESULT WINAPI
AtlComModuleUnregisterServer(_ATL_COM_MODULE
*mod
, BOOL bRegTypeLib
, const CLSID
*clsid
)
560 const struct _ATL_CATMAP_ENTRY
*catmap
;
561 _ATL_OBJMAP_ENTRY
**iter
;
564 TRACE("(%p %x %s)\n", mod
, bRegTypeLib
, debugstr_guid(clsid
));
566 for(iter
= mod
->m_ppAutoObjMapFirst
; iter
< mod
->m_ppAutoObjMapLast
; iter
++) {
567 if(!*iter
|| (clsid
&& !IsEqualCLSID((*iter
)->pclsid
, clsid
)))
570 TRACE("Unregistering clsid %s\n", debugstr_guid((*iter
)->pclsid
));
572 catmap
= (*iter
)->pfnGetCategoryMap();
574 hres
= AtlRegisterClassCategoriesHelper((*iter
)->pclsid
, catmap
, FALSE
);
579 hres
= (*iter
)->pfnUpdateRegistry(FALSE
);
589 hres
= AtlLoadTypeLib(mod
->m_hInstTypeLib
, NULL
, &path
, &typelib
);
594 hres
= ITypeLib_GetLibAttr(typelib
, &attr
);
595 if(SUCCEEDED(hres
)) {
596 hres
= UnRegisterTypeLib(&attr
->guid
, attr
->wMajorVerNum
, attr
->wMinorVerNum
, attr
->lcid
, attr
->syskind
);
597 ITypeLib_ReleaseTLibAttr(typelib
, attr
);
599 ITypeLib_Release(typelib
);
609 /***********************************************************************
610 * AtlRegisterClassCategoriesHelper [atl100.49]
612 HRESULT WINAPI
AtlRegisterClassCategoriesHelper(REFCLSID clsid
, const struct _ATL_CATMAP_ENTRY
*catmap
, BOOL reg
)
614 const struct _ATL_CATMAP_ENTRY
*iter
;
617 TRACE("(%s %p %x)\n", debugstr_guid(clsid
), catmap
, reg
);
623 ICatRegister
*new_catreg
;
625 hres
= CoCreateInstance(&CLSID_StdComponentCategoriesMgr
, NULL
, CLSCTX_INPROC_SERVER
,
626 &IID_ICatRegister
, (void**)&new_catreg
);
630 if(InterlockedCompareExchangePointer((void**)&catreg
, new_catreg
, NULL
))
631 ICatRegister_Release(new_catreg
);
634 for(iter
= catmap
; iter
->iType
!= _ATL_CATMAP_ENTRY_END
; iter
++) {
635 CATID catid
= *iter
->pcatid
; /* For stupid lack of const in ICatRegister declaration. */
637 if(iter
->iType
== _ATL_CATMAP_ENTRY_IMPLEMENTED
) {
639 hres
= ICatRegister_RegisterClassImplCategories(catreg
, clsid
, 1, &catid
);
641 hres
= ICatRegister_UnRegisterClassImplCategories(catreg
, clsid
, 1, &catid
);
644 hres
= ICatRegister_RegisterClassReqCategories(catreg
, clsid
, 1, &catid
);
646 hres
= ICatRegister_UnRegisterClassReqCategories(catreg
, clsid
, 1, &catid
);
653 WCHAR reg_path
[256] = {'C','L','S','I','D','\\'}, *ptr
= reg_path
+6;
655 static const WCHAR implemented_catW
[] =
656 {'I','m','p','l','e','m','e','n','t','e','d',' ','C','a','t','e','g','o','r','i','e','s',0};
657 static const WCHAR required_catW
[] =
658 {'R','e','q','u','i','r','e','d',' ','C','a','t','e','g','o','r','i','e','s',0};
660 ptr
+= StringFromGUID2(clsid
, ptr
, 64)-1;
663 memcpy(ptr
, implemented_catW
, sizeof(implemented_catW
));
664 RegDeleteKeyW(HKEY_CLASSES_ROOT
, reg_path
);
666 memcpy(ptr
, required_catW
, sizeof(required_catW
));
667 RegDeleteKeyW(HKEY_CLASSES_ROOT
, reg_path
);
673 /***********************************************************************
674 * AtlWaitWithMessageLoop [atl100.24]
676 BOOL WINAPI
AtlWaitWithMessageLoop(HANDLE handle
)
681 TRACE("(%p)\n", handle
);
684 res
= MsgWaitForMultipleObjects(1, &handle
, FALSE
, INFINITE
, QS_ALLINPUT
);
688 case WAIT_OBJECT_0
+1:
689 if(GetMessageW(&msg
, NULL
, 0, 0) < 0)
692 TranslateMessage(&msg
);
693 DispatchMessageW(&msg
);
701 static HRESULT
get_default_source(ITypeLib
*typelib
, const CLSID
*clsid
, IID
*iid
)
703 ITypeInfo
*typeinfo
, *src_typeinfo
= NULL
;
709 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, clsid
, &typeinfo
);
713 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &attr
);
715 ITypeInfo_Release(typeinfo
);
719 for(i
=0; i
< attr
->cImplTypes
; i
++) {
720 hres
= ITypeInfo_GetImplTypeFlags(typeinfo
, i
, &type_flags
);
721 if(SUCCEEDED(hres
) && type_flags
== (IMPLTYPEFLAG_FSOURCE
|IMPLTYPEFLAG_FDEFAULT
)) {
724 hres
= ITypeInfo_GetRefTypeOfImplType(typeinfo
, i
, &ref
);
726 hres
= ITypeInfo_GetRefTypeInfo(typeinfo
, ref
, &src_typeinfo
);
731 ITypeInfo_ReleaseTypeAttr(typeinfo
, attr
);
732 ITypeInfo_Release(typeinfo
);
741 hres
= ITypeInfo_GetTypeAttr(src_typeinfo
, &attr
);
742 if(SUCCEEDED(hres
)) {
744 ITypeInfo_ReleaseTypeAttr(src_typeinfo
, attr
);
746 ITypeInfo_Release(src_typeinfo
);
750 /***********************************************************************
751 * AtlGetObjectSourceInterface [atl100.54]
753 HRESULT WINAPI
AtlGetObjectSourceInterface(IUnknown
*unk
, GUID
*libid
, IID
*iid
, unsigned short *major
, unsigned short *minor
)
755 IProvideClassInfo2
*classinfo
;
762 TRACE("(%p %p %p %p %p)\n", unk
, libid
, iid
, major
, minor
);
764 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp
);
768 hres
= IDispatch_GetTypeInfo(disp
, 0, 0, &typeinfo
);
769 IDispatch_Release(disp
);
773 hres
= ITypeInfo_GetContainingTypeLib(typeinfo
, &typelib
, 0);
774 ITypeInfo_Release(typeinfo
);
775 if(SUCCEEDED(hres
)) {
778 hres
= ITypeLib_GetLibAttr(typelib
, &attr
);
779 if(SUCCEEDED(hres
)) {
781 *major
= attr
->wMajorVerNum
;
782 *minor
= attr
->wMinorVerNum
;
783 ITypeLib_ReleaseTLibAttr(typelib
, attr
);
785 ITypeLib_Release(typelib
);
791 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo2
, (void**)&classinfo
);
792 if(SUCCEEDED(hres
)) {
793 hres
= IProvideClassInfo2_GetGUID(classinfo
, GUIDKIND_DEFAULT_SOURCE_DISP_IID
, iid
);
794 IProvideClassInfo2_Release(classinfo
);
795 ITypeLib_Release(typelib
);
799 hres
= IUnknown_QueryInterface(unk
, &IID_IPersist
, (void**)&persist
);
800 if(SUCCEEDED(hres
)) {
803 hres
= IPersist_GetClassID(persist
, &clsid
);
805 hres
= get_default_source(typelib
, &clsid
, iid
);
806 IPersist_Release(persist
);
812 #if _ATL_VER >= _ATL_VER90
814 /***********************************************************************
815 * AtlSetPerUserRegistration [atl100.67]
817 HRESULT WINAPI
AtlSetPerUserRegistration(cpp_bool bEnable
)
819 FIXME("stub: bEnable: %d\n", bEnable
);
823 /***********************************************************************
824 * AtlGetPerUserRegistration [atl100.68]
826 HRESULT WINAPI
AtlGetPerUserRegistration(cpp_bool
*pbEnabled
)
828 FIXME("stub: returning false\n");
835 /***********************************************************************
836 * AtlGetVersion [atl100.@]
838 DWORD WINAPI
AtlGetVersion(void *pReserved
)
840 TRACE("version %04x (%p)\n", _ATL_VER
, pReserved
);
844 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
846 TRACE("(0x%p, %d, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
849 case DLL_PROCESS_ATTACH
:
850 atl_instance
= hinstDLL
;
851 DisableThreadLibraryCalls(hinstDLL
);
853 case DLL_PROCESS_DETACH
:
854 if (lpvReserved
) break;
856 ICatRegister_Release(catreg
);