Move the Dll init function to compobj.c to avoid having global

variables. Remove need of ole32_main.h.
This commit is contained in:
Marcus Meissner 2005-05-16 14:12:53 +00:00 committed by Alexandre Julliard
parent 08cf5a301a
commit f3d99b2697
6 changed files with 40 additions and 75 deletions

View File

@ -66,7 +66,6 @@
#include "wownt32.h" #include "wownt32.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "objbase.h" #include "objbase.h"
#include "ole32_main.h"
#include "compobj_private.h" #include "compobj_private.h"
#include "wine/debug.h" #include "wine/debug.h"
@ -75,6 +74,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
typedef LPCSTR LPCOLESTR16; typedef LPCSTR LPCOLESTR16;
HINSTANCE OLE32_hInstance = 0; /* FIXME: make static ... */
/**************************************************************************** /****************************************************************************
* This section defines variables internal to the COM module. * This section defines variables internal to the COM module.
* *
@ -169,7 +170,7 @@ static LRESULT CALLBACK apartment_wndproc(HWND hWnd, UINT msg, WPARAM wParam, LP
static void COMPOBJ_DLLList_Add(HANDLE hLibrary); static void COMPOBJ_DLLList_Add(HANDLE hLibrary);
static void COMPOBJ_DllList_FreeUnused(int Timeout); static void COMPOBJ_DllList_FreeUnused(int Timeout);
void COMPOBJ_InitProcess( void ) static void COMPOBJ_InitProcess( void )
{ {
WNDCLASSW wclass; WNDCLASSW wclass;
@ -189,12 +190,12 @@ void COMPOBJ_InitProcess( void )
RegisterClassW(&wclass); RegisterClassW(&wclass);
} }
void COMPOBJ_UninitProcess( void ) static void COMPOBJ_UninitProcess( void )
{ {
UnregisterClassW(wszAptWinClass, OLE32_hInstance); UnregisterClassW(wszAptWinClass, OLE32_hInstance);
} }
void COM_TlsDestroy() static void COM_TlsDestroy()
{ {
struct oletls *info = NtCurrentTeb()->ReservedForOle; struct oletls *info = NtCurrentTeb()->ReservedForOle;
if (info) if (info)
@ -624,7 +625,7 @@ HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
/* On COM finalization for a STA thread, the message queue is flushed to ensure no /* On COM finalization for a STA thread, the message queue is flushed to ensure no
pending RPCs are ignored. Non-COM messages are discarded at this point. pending RPCs are ignored. Non-COM messages are discarded at this point.
*/ */
void COM_FlushMessageQueue(void) static void COM_FlushMessageQueue(void)
{ {
MSG message; MSG message;
APARTMENT *apt = COM_CurrentApt(); APARTMENT *apt = COM_CurrentApt();
@ -1531,7 +1532,8 @@ end:
* *
* Reads a registry value and expands it when necessary * Reads a registry value and expands it when necessary
*/ */
HRESULT compobj_RegReadPath(char * keyname, char * valuename, char * dst, DWORD dstlen) static HRESULT
compobj_RegReadPath(char * keyname, char * valuename, char * dst, DWORD dstlen)
{ {
HRESULT hres; HRESULT hres;
HKEY key; HKEY key;
@ -2654,3 +2656,32 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout,
TRACE("-- 0x%08lx\n", hr); TRACE("-- 0x%08lx\n", hr);
return hr; return hr;
} }
/***********************************************************************
* DllMain (OLE32.@)
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
{
TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
OLE32_hInstance = hinstDLL;
COMPOBJ_InitProcess();
if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1);
break;
case DLL_PROCESS_DETACH:
if (TRACE_ON(ole)) CoRevokeMallocSpy();
COMPOBJ_UninitProcess();
OLE32_hInstance = 0;
break;
case DLL_THREAD_DETACH:
COM_TlsDestroy();
break;
}
return TRUE;
}
/* NOTE: DllRegisterServer and DllUnregisterServer are in regsvr.c */

View File

@ -254,4 +254,6 @@ static inline APARTMENT* COM_CurrentApt(void)
# define DEBUG_CLEAR_CRITSEC_NAME(cs) # define DEBUG_CLEAR_CRITSEC_NAME(cs)
#endif #endif
extern HINSTANCE OLE32_hInstance; /* FIXME: make static */
#endif /* __WINE_OLE_COMPOBJ_H */ #endif /* __WINE_OLE_COMPOBJ_H */

View File

@ -48,7 +48,6 @@
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "wine/wingdi16.h" #include "wine/wingdi16.h"
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "ole32_main.h"
#include "compobj_private.h" #include "compobj_private.h"
#include "wine/debug.h" #include "wine/debug.h"

View File

@ -45,7 +45,6 @@
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "wine/wingdi16.h" #include "wine/wingdi16.h"
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "ole32_main.h"
#include "ifs.h" #include "ifs.h"
#include "wine/debug.h" #include "wine/debug.h"

View File

@ -27,13 +27,11 @@
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "winnls.h" #include "winnls.h"
#include "ole32_main.h" #include "objbase.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole); WINE_DEFAULT_DEBUG_CHANNEL(ole);
HINSTANCE OLE32_hInstance = 0;
/*********************************************************************** /***********************************************************************
* OleMetafilePictFromIconAndLabel (OLE32.@) * OleMetafilePictFromIconAndLabel (OLE32.@)
*/ */
@ -110,33 +108,3 @@ HGLOBAL WINAPI OleMetafilePictFromIconAndLabel(HICON hIcon, LPOLESTR lpszLabel,
return hmem; return hmem;
} }
/***********************************************************************
* DllMain (OLE32.@)
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
{
TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
OLE32_hInstance = hinstDLL;
COMPOBJ_InitProcess();
if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1);
break;
case DLL_PROCESS_DETACH:
if (TRACE_ON(ole)) CoRevokeMallocSpy();
COMPOBJ_UninitProcess();
OLE32_hInstance = 0;
break;
case DLL_THREAD_DETACH:
COM_TlsDestroy();
break;
}
return TRUE;
}
/* NOTE: DllRegisterServer and DllUnregisterServer are in regsvr.c */

View File

@ -1,34 +0,0 @@
/*
* Copyright 2000 Huw D M Davies for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_OLE32_MAIN_H
#define __WINE_OLE32_MAIN_H
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
extern HINSTANCE OLE32_hInstance;
void COMPOBJ_InitProcess( void );
void COMPOBJ_UninitProcess( void );
void COM_TlsDestroy( void );
#endif /* __WINE_OLE32_MAIN_H */