From 3475dcdb93cbb6348c198baba1d4a6d650915dda Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 17 Mar 2005 10:24:42 +0000 Subject: [PATCH] Added implementation of DllCanUnloadNow. --- dlls/atl/atl.spec | 2 +- dlls/atl/registrar.c | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/dlls/atl/atl.spec b/dlls/atl/atl.spec index 105a91ed921..e33804b671e 100644 --- a/dlls/atl/atl.spec +++ b/dlls/atl/atl.spec @@ -1,4 +1,4 @@ -1 stub DllCanUnloadNow +1 stdcall -private DllCanUnloadNow() ATL_DllCanUnloadNow 2 stdcall -private DllGetClassObject(ptr ptr ptr) ATL_DllGetClassObject 3 stdcall -private DllRegisterServer() ATL_DllRegisterServer 4 stdcall -private DllUnregisterServer() ATL_DllUnregisterServer diff --git a/dlls/atl/registrar.c b/dlls/atl/registrar.c index ac8d4cb61e0..aa716ac043d 100644 --- a/dlls/atl/registrar.c +++ b/dlls/atl/registrar.c @@ -37,6 +37,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(atl); +ULONG dll_count = 0; + /************************************************************** * ATLRegistrar implementation */ @@ -478,6 +480,7 @@ static ULONG WINAPI Registrar_Release(IRegistrar *iface) if(!ref) { IRegistrar_ClearReplacements(iface); HeapFree(GetProcessHeap(), 0, This); + InterlockedDecrement(&dll_count); } return ref; } @@ -618,6 +621,8 @@ static HRESULT Registrar_create(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObje ret->rep = NULL; *ppvObject = ret; + InterlockedIncrement(&dll_count); + return S_OK; } @@ -639,11 +644,13 @@ static HRESULT WINAPI RegistrarCF_QueryInterface(IClassFactory *iface, REFIID ri static ULONG WINAPI RegistrarCF_AddRef(IClassFactory *iface) { + InterlockedIncrement(&dll_count); return 2; } static ULONG WINAPI RegistrarCF_Release(IClassFactory *iface) { + InterlockedDecrement(&dll_count); return 1; } @@ -656,7 +663,13 @@ static HRESULT WINAPI RegistrarCF_CreateInstance(IClassFactory *iface, LPUNKNOWN static HRESULT WINAPI RegistrarCF_LockServer(IClassFactory *iface, BOOL lock) { - FIXME("(%p)->(%x)\n", iface, lock); + TRACE("(%p)->(%x)\n", iface, lock); + + if(lock) + InterlockedIncrement(&dll_count); + else + InterlockedDecrement(&dll_count); + return S_OK; } @@ -732,3 +745,12 @@ HRESULT WINAPI ATL_DllUnregisterServer(void) TRACE("\n"); return do_register_server(FALSE); } + +/*********************************************************************** + * DllCanUnloadNow (ATL.@) + */ +HRESULT WINAPI ATL_DllCanUnloadNow(void) +{ + TRACE("dll_count = %lu\n", dll_count); + return dll_count ? S_FALSE : S_OK; +}