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* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size
)
38 return HeapAlloc(GetProcessHeap(), 0, size
);
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 * AtlIPersistPropertyBag_Save [atl100.@]
291 HRESULT WINAPI
AtlIPersistPropertyBag_Save(LPPROPERTYBAG pPropBag
, BOOL fClearDirty
,
292 BOOL fSaveAll
, ATL_PROPMAP_ENTRY
*pMap
,
293 void *pThis
, IUnknown
*pUnk
)
295 FIXME("(%p, %d, %d, %p, %p, %p)\n", pPropBag
, fClearDirty
, fSaveAll
, pMap
, pThis
, pUnk
);
300 /***********************************************************************
301 * AtlModuleAddTermFunc [atl100.@]
303 HRESULT WINAPI
AtlModuleAddTermFunc(_ATL_MODULE
*pM
, _ATL_TERMFUNC
*pFunc
, DWORD_PTR dw
)
305 _ATL_TERMFUNC_ELEM
*termfunc_elem
;
307 TRACE("version %04x (%p %p %ld)\n", _ATL_VER
, pM
, pFunc
, dw
);
309 if (_ATL_VER
> _ATL_VER_30
|| pM
->cbSize
> ATLVer1Size
) {
310 termfunc_elem
= HeapAlloc(GetProcessHeap(), 0, sizeof(_ATL_TERMFUNC_ELEM
));
311 termfunc_elem
->pFunc
= pFunc
;
312 termfunc_elem
->dw
= dw
;
313 termfunc_elem
->pNext
= pM
->m_pTermFuncs
;
315 pM
->m_pTermFuncs
= termfunc_elem
;
321 #if _ATL_VER > _ATL_VER_30
323 /***********************************************************************
324 * AtlCallTermFunc [atl100.@]
326 void WINAPI
AtlCallTermFunc(_ATL_MODULE
*pM
)
328 _ATL_TERMFUNC_ELEM
*iter
= pM
->m_pTermFuncs
, *tmp
;
333 iter
->pFunc(iter
->dw
);
336 HeapFree(GetProcessHeap(), 0, tmp
);
339 pM
->m_pTermFuncs
= NULL
;
344 /***********************************************************************
345 * AtlLoadTypeLib [atl100.56]
347 HRESULT WINAPI
AtlLoadTypeLib(HINSTANCE inst
, LPCOLESTR lpszIndex
,
348 BSTR
*pbstrPath
, ITypeLib
**ppTypeLib
)
350 size_t path_len
, index_len
;
351 ITypeLib
*typelib
= NULL
;
355 static const WCHAR tlb_extW
[] = {'.','t','l','b',0};
357 TRACE("(%p %s %p %p)\n", inst
, debugstr_w(lpszIndex
), pbstrPath
, ppTypeLib
);
359 index_len
= lpszIndex
? strlenW(lpszIndex
) : 0;
360 path
= heap_alloc((MAX_PATH
+index_len
)*sizeof(WCHAR
) + sizeof(tlb_extW
));
362 return E_OUTOFMEMORY
;
364 path_len
= GetModuleFileNameW(inst
, path
, MAX_PATH
);
367 return HRESULT_FROM_WIN32(GetLastError());
371 memcpy(path
+path_len
, lpszIndex
, (index_len
+1)*sizeof(WCHAR
));
373 hres
= LoadTypeLib(path
, &typelib
);
377 for(ptr
= path
+path_len
-1; ptr
> path
&& *ptr
!= '\\' && *ptr
!= '.'; ptr
--);
380 memcpy(ptr
, tlb_extW
, sizeof(tlb_extW
));
381 hres
= LoadTypeLib(path
, &typelib
);
384 if(SUCCEEDED(hres
)) {
385 *pbstrPath
= SysAllocString(path
);
387 ITypeLib_Release(typelib
);
388 hres
= E_OUTOFMEMORY
;
396 *ppTypeLib
= typelib
;
400 #if _ATL_VER <= _ATL_VER_80
402 /***********************************************************************
403 * AtlRegisterTypeLib [atl80.19]
405 HRESULT WINAPI
AtlRegisterTypeLib(HINSTANCE inst
, const WCHAR
*index
)
411 TRACE("(%p %s)\n", inst
, debugstr_w(index
));
413 hres
= AtlLoadTypeLib(inst
, index
, &path
, &typelib
);
417 hres
= RegisterTypeLib(typelib
, path
, NULL
); /* FIXME: pass help directory */
418 ITypeLib_Release(typelib
);
425 #if _ATL_VER > _ATL_VER_30
427 /***********************************************************************
428 * AtlWinModuleInit [atl100.65]
430 HRESULT WINAPI
AtlWinModuleInit(_ATL_WIN_MODULE
*winmod
)
432 TRACE("(%p)\n", winmod
);
434 if(winmod
->cbSize
!= sizeof(*winmod
))
437 InitializeCriticalSection(&winmod
->m_csWindowCreate
);
438 winmod
->m_pCreateWndList
= NULL
;
442 /***********************************************************************
443 * AtlWinModuleAddCreateWndData [atl100.43]
445 void WINAPI
AtlWinModuleAddCreateWndData(_ATL_WIN_MODULE
*pM
, _AtlCreateWndData
*pData
, void *pvObject
)
447 TRACE("(%p, %p, %p)\n", pM
, pData
, pvObject
);
449 pData
->m_pThis
= pvObject
;
450 pData
->m_dwThreadID
= GetCurrentThreadId();
452 EnterCriticalSection(&pM
->m_csWindowCreate
);
453 pData
->m_pNext
= pM
->m_pCreateWndList
;
454 pM
->m_pCreateWndList
= pData
;
455 LeaveCriticalSection(&pM
->m_csWindowCreate
);
458 /***********************************************************************
459 * AtlWinModuleExtractCreateWndData [atl100.44]
461 void* WINAPI
AtlWinModuleExtractCreateWndData(_ATL_WIN_MODULE
*winmod
)
463 _AtlCreateWndData
*iter
, *prev
= NULL
;
466 TRACE("(%p)\n", winmod
);
468 thread_id
= GetCurrentThreadId();
470 EnterCriticalSection(&winmod
->m_csWindowCreate
);
472 for(iter
= winmod
->m_pCreateWndList
; iter
&& iter
->m_dwThreadID
!= thread_id
; iter
= iter
->m_pNext
)
476 prev
->m_pNext
= iter
->m_pNext
;
478 winmod
->m_pCreateWndList
= iter
->m_pNext
;
481 LeaveCriticalSection(&winmod
->m_csWindowCreate
);
483 return iter
? iter
->m_pThis
: NULL
;
486 /***********************************************************************
487 * AtlComModuleGetClassObject [atl100.15]
489 HRESULT WINAPI
AtlComModuleGetClassObject(_ATL_COM_MODULE
*pm
, REFCLSID rclsid
, REFIID riid
, void **ppv
)
491 _ATL_OBJMAP_ENTRY
**iter
;
494 TRACE("(%p %s %s %p)\n", pm
, debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
499 for(iter
= pm
->m_ppAutoObjMapFirst
; iter
< pm
->m_ppAutoObjMapLast
; iter
++) {
500 if(IsEqualCLSID((*iter
)->pclsid
, rclsid
) && (*iter
)->pfnGetClassObject
) {
502 hres
= (*iter
)->pfnGetClassObject((*iter
)->pfnCreateInstance
, &IID_IUnknown
, (void**)&(*iter
)->pCF
);
504 hres
= IUnknown_QueryInterface((*iter
)->pCF
, riid
, ppv
);
505 TRACE("returning %p (%08x)\n", *ppv
, hres
);
510 WARN("Class %s not found\n", debugstr_guid(rclsid
));
511 return CLASS_E_CLASSNOTAVAILABLE
;
514 /***********************************************************************
515 * AtlComModuleRegisterClassObjects [atl100.17]
517 HRESULT WINAPI
AtlComModuleRegisterClassObjects(_ATL_COM_MODULE
*module
, DWORD context
, DWORD flags
)
519 _ATL_OBJMAP_ENTRY
**iter
;
523 TRACE("(%p %x %x)\n", module
, context
, flags
);
528 for(iter
= module
->m_ppAutoObjMapFirst
; iter
< module
->m_ppAutoObjMapLast
; iter
++) {
529 if(!(*iter
)->pfnGetClassObject
)
532 hres
= (*iter
)->pfnGetClassObject((*iter
)->pfnCreateInstance
, &IID_IUnknown
, (void**)&unk
);
536 hres
= CoRegisterClassObject((*iter
)->pclsid
, unk
, context
, flags
, &(*iter
)->dwRegister
);
537 IUnknown_Release(unk
);
545 /***********************************************************************
546 * AtlComModuleRevokeClassObjects [atl100.20]
548 HRESULT WINAPI
AtlComModuleRevokeClassObjects(_ATL_COM_MODULE
*module
)
550 _ATL_OBJMAP_ENTRY
**iter
;
553 TRACE("(%p)\n", module
);
558 for(iter
= module
->m_ppAutoObjMapFirst
; iter
< module
->m_ppAutoObjMapLast
; iter
++) {
559 hres
= CoRevokeClassObject((*iter
)->dwRegister
);
567 /***********************************************************************
568 * AtlComModuleUnregisterServer [atl100.22]
570 HRESULT WINAPI
AtlComModuleUnregisterServer(_ATL_COM_MODULE
*mod
, BOOL bRegTypeLib
, const CLSID
*clsid
)
572 const struct _ATL_CATMAP_ENTRY
*catmap
;
573 _ATL_OBJMAP_ENTRY
**iter
;
576 TRACE("(%p %x %s)\n", mod
, bRegTypeLib
, debugstr_guid(clsid
));
578 for(iter
= mod
->m_ppAutoObjMapFirst
; iter
< mod
->m_ppAutoObjMapLast
; iter
++) {
579 if(!*iter
|| (clsid
&& !IsEqualCLSID((*iter
)->pclsid
, clsid
)))
582 TRACE("Unregistering clsid %s\n", debugstr_guid((*iter
)->pclsid
));
584 catmap
= (*iter
)->pfnGetCategoryMap();
586 hres
= AtlRegisterClassCategoriesHelper((*iter
)->pclsid
, catmap
, FALSE
);
591 hres
= (*iter
)->pfnUpdateRegistry(FALSE
);
601 hres
= AtlLoadTypeLib(mod
->m_hInstTypeLib
, NULL
, &path
, &typelib
);
606 hres
= ITypeLib_GetLibAttr(typelib
, &attr
);
607 if(SUCCEEDED(hres
)) {
608 hres
= UnRegisterTypeLib(&attr
->guid
, attr
->wMajorVerNum
, attr
->wMinorVerNum
, attr
->lcid
, attr
->syskind
);
609 ITypeLib_ReleaseTLibAttr(typelib
, attr
);
611 ITypeLib_Release(typelib
);
621 /***********************************************************************
622 * AtlRegisterClassCategoriesHelper [atl100.49]
624 HRESULT WINAPI
AtlRegisterClassCategoriesHelper(REFCLSID clsid
, const struct _ATL_CATMAP_ENTRY
*catmap
, BOOL reg
)
626 const struct _ATL_CATMAP_ENTRY
*iter
;
629 TRACE("(%s %p %x)\n", debugstr_guid(clsid
), catmap
, reg
);
635 ICatRegister
*new_catreg
;
637 hres
= CoCreateInstance(&CLSID_StdComponentCategoriesMgr
, NULL
, CLSCTX_INPROC_SERVER
,
638 &IID_ICatRegister
, (void**)&new_catreg
);
642 if(InterlockedCompareExchangePointer((void**)&catreg
, new_catreg
, NULL
))
643 ICatRegister_Release(new_catreg
);
646 for(iter
= catmap
; iter
->iType
!= _ATL_CATMAP_ENTRY_END
; iter
++) {
647 CATID catid
= *iter
->pcatid
; /* For stupid lack of const in ICatRegister declaration. */
649 if(iter
->iType
== _ATL_CATMAP_ENTRY_IMPLEMENTED
) {
651 hres
= ICatRegister_RegisterClassImplCategories(catreg
, clsid
, 1, &catid
);
653 hres
= ICatRegister_UnRegisterClassImplCategories(catreg
, clsid
, 1, &catid
);
656 hres
= ICatRegister_RegisterClassReqCategories(catreg
, clsid
, 1, &catid
);
658 hres
= ICatRegister_UnRegisterClassReqCategories(catreg
, clsid
, 1, &catid
);
665 WCHAR reg_path
[256] = {'C','L','S','I','D','\\'}, *ptr
= reg_path
+6;
667 static const WCHAR implemented_catW
[] =
668 {'I','m','p','l','e','m','e','n','t','e','d',' ','C','a','t','e','g','o','r','i','e','s',0};
669 static const WCHAR required_catW
[] =
670 {'R','e','q','u','i','r','e','d',' ','C','a','t','e','g','o','r','i','e','s',0};
672 ptr
+= StringFromGUID2(clsid
, ptr
, 64)-1;
675 memcpy(ptr
, implemented_catW
, sizeof(implemented_catW
));
676 RegDeleteKeyW(HKEY_CLASSES_ROOT
, reg_path
);
678 memcpy(ptr
, required_catW
, sizeof(required_catW
));
679 RegDeleteKeyW(HKEY_CLASSES_ROOT
, reg_path
);
685 /***********************************************************************
686 * AtlWaitWithMessageLoop [atl100.24]
688 BOOL WINAPI
AtlWaitWithMessageLoop(HANDLE handle
)
693 TRACE("(%p)\n", handle
);
696 res
= MsgWaitForMultipleObjects(1, &handle
, FALSE
, INFINITE
, QS_ALLINPUT
);
700 case WAIT_OBJECT_0
+1:
701 if(GetMessageW(&msg
, NULL
, 0, 0) < 0)
704 TranslateMessage(&msg
);
705 DispatchMessageW(&msg
);
713 static HRESULT
get_default_source(ITypeLib
*typelib
, const CLSID
*clsid
, IID
*iid
)
715 ITypeInfo
*typeinfo
, *src_typeinfo
= NULL
;
721 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, clsid
, &typeinfo
);
725 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &attr
);
727 ITypeInfo_Release(typeinfo
);
731 for(i
=0; i
< attr
->cImplTypes
; i
++) {
732 hres
= ITypeInfo_GetImplTypeFlags(typeinfo
, i
, &type_flags
);
733 if(SUCCEEDED(hres
) && type_flags
== (IMPLTYPEFLAG_FSOURCE
|IMPLTYPEFLAG_FDEFAULT
)) {
736 hres
= ITypeInfo_GetRefTypeOfImplType(typeinfo
, i
, &ref
);
738 hres
= ITypeInfo_GetRefTypeInfo(typeinfo
, ref
, &src_typeinfo
);
743 ITypeInfo_ReleaseTypeAttr(typeinfo
, attr
);
744 ITypeInfo_Release(typeinfo
);
753 hres
= ITypeInfo_GetTypeAttr(src_typeinfo
, &attr
);
754 if(SUCCEEDED(hres
)) {
756 ITypeInfo_ReleaseTypeAttr(src_typeinfo
, attr
);
758 ITypeInfo_Release(src_typeinfo
);
762 /***********************************************************************
763 * AtlGetObjectSourceInterface [atl100.54]
765 HRESULT WINAPI
AtlGetObjectSourceInterface(IUnknown
*unk
, GUID
*libid
, IID
*iid
, unsigned short *major
, unsigned short *minor
)
767 IProvideClassInfo2
*classinfo
;
774 TRACE("(%p %p %p %p %p)\n", unk
, libid
, iid
, major
, minor
);
776 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp
);
780 hres
= IDispatch_GetTypeInfo(disp
, 0, 0, &typeinfo
);
781 IDispatch_Release(disp
);
785 hres
= ITypeInfo_GetContainingTypeLib(typeinfo
, &typelib
, 0);
786 ITypeInfo_Release(typeinfo
);
787 if(SUCCEEDED(hres
)) {
790 hres
= ITypeLib_GetLibAttr(typelib
, &attr
);
791 if(SUCCEEDED(hres
)) {
793 *major
= attr
->wMajorVerNum
;
794 *minor
= attr
->wMinorVerNum
;
795 ITypeLib_ReleaseTLibAttr(typelib
, attr
);
797 ITypeLib_Release(typelib
);
803 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo2
, (void**)&classinfo
);
804 if(SUCCEEDED(hres
)) {
805 hres
= IProvideClassInfo2_GetGUID(classinfo
, GUIDKIND_DEFAULT_SOURCE_DISP_IID
, iid
);
806 IProvideClassInfo2_Release(classinfo
);
807 ITypeLib_Release(typelib
);
811 hres
= IUnknown_QueryInterface(unk
, &IID_IPersist
, (void**)&persist
);
812 if(SUCCEEDED(hres
)) {
815 hres
= IPersist_GetClassID(persist
, &clsid
);
817 hres
= get_default_source(typelib
, &clsid
, iid
);
818 IPersist_Release(persist
);
824 #if _ATL_VER >= _ATL_VER90
826 /***********************************************************************
827 * AtlSetPerUserRegistration [atl100.67]
829 HRESULT WINAPI
AtlSetPerUserRegistration(cpp_bool bEnable
)
831 FIXME("stub: bEnable: %d\n", bEnable
);
835 /***********************************************************************
836 * AtlGetPerUserRegistration [atl100.68]
838 HRESULT WINAPI
AtlGetPerUserRegistration(cpp_bool
*pbEnabled
)
840 FIXME("stub: returning false\n");
847 /***********************************************************************
848 * AtlGetVersion [atl100.@]
850 DWORD WINAPI
AtlGetVersion(void *pReserved
)
852 TRACE("version %04x (%p)\n", _ATL_VER
, pReserved
);
856 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
858 TRACE("(0x%p, %d, %p)\n", hinstDLL
, fdwReason
, lpvReserved
);
861 case DLL_PROCESS_ATTACH
:
862 atl_instance
= hinstDLL
;
863 DisableThreadLibraryCalls(hinstDLL
);
865 case DLL_PROCESS_DETACH
:
866 if (lpvReserved
) break;
868 ICatRegister_Release(catreg
);