Kaydet (Commit) b24957e8 authored tarafından Michael Stahl's avatar Michael Stahl

clean up some COM initialization

CoInitialize{Ex] always exist in all supported Win32 versions, so just
call them.

Change-Id: I45f227319aae811b6c94a3ac475467a06146b8e9
üst 95759ff2
...@@ -79,31 +79,18 @@ void *CurThreadData::getData() ...@@ -79,31 +79,18 @@ void *CurThreadData::getData()
return (osl_getThreadKeyData(m_hKey)); return (osl_getThreadKeyData(m_hKey));
} }
// CoInitializeEx *
typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInitEx)( LPVOID, DWORD);
// CoInitialize *
typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInit)( LPVOID);
void o2u_attachCurrentThread() void o2u_attachCurrentThread()
{ {
static CurThreadData oleThreadData; static CurThreadData oleThreadData;
if ( oleThreadData.getData() != 0 ) if ( oleThreadData.getData() != 0 )
{ {
HINSTANCE inst= LoadLibrary( _T("ole32.dll")); HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);
if( inst ) if (!SUCCEEDED(hr))
{ { // FIXME: is it a problem that this ends up in STA currently?
HRESULT hr; assert(RPC_E_CHANGED_MODE == hr);
ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress( inst, _T("CoInitializeEx")); SAL_INFO("embedserv.ole",
if( initFuncEx) "CoInitializeEx fail: probably thread is in STA already?");
hr= initFuncEx( NULL, COINIT_MULTITHREADED);
else
{
ptrCoInit initFunc= (ptrCoInit)GetProcAddress( inst,_T("CoInitialize"));
if( initFunc)
hr= initFunc( NULL);
}
} }
oleThreadData.setData((void*)sal_True); oleThreadData.setData((void*)sal_True);
} }
......
...@@ -25,10 +25,6 @@ using namespace std; ...@@ -25,10 +25,6 @@ using namespace std;
namespace ole_adapter namespace ole_adapter
{ {
// CoInitializeEx *
typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInitEx)( LPVOID, DWORD);
// CoInitialize *
typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInit)( LPVOID);
void o2u_attachCurrentThread() void o2u_attachCurrentThread()
{ {
...@@ -36,21 +32,12 @@ void o2u_attachCurrentThread() ...@@ -36,21 +32,12 @@ void o2u_attachCurrentThread()
if ((sal_Bool)(sal_IntPtr)oleThreadData.getData() != sal_True) if ((sal_Bool)(sal_IntPtr)oleThreadData.getData() != sal_True)
{ {
HINSTANCE inst= LoadLibrary( _T("ole32.dll")); HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);
if( inst ) if (!SUCCEEDED(hr))
{ { // FIXME: is it a problem that this ends up in STA currently?
HRESULT hr; assert(RPC_E_CHANGED_MODE == hr);
// Try DCOM SAL_INFO("extensions.olebridge",
ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress( inst, _T("CoInitializeEx")); "CoInitializeEx fail: probably thread is in STA already?");
if( initFuncEx)
hr= initFuncEx( NULL, COINIT_MULTITHREADED);
// No DCOM, try COM
else
{
ptrCoInit initFunc= (ptrCoInit)GetProcAddress( inst,_T("CoInitialize"));
if( initFunc)
hr= initFunc( NULL);
}
} }
oleThreadData.setData((void*)sal_True); oleThreadData.setData((void*)sal_True);
} }
......
...@@ -126,12 +126,17 @@ certain functionality. ...@@ -126,12 +126,17 @@ certain functionality.
@li @c embeddedobj.general @li @c embeddedobj.general
@li @c embeddedobj.ole - OLE embedded objects @li @c embeddedobj.ole - OLE embedded objects
@section embedserv
@li @c embedserv - embedding server
@li @c embedserv.ole - OLE server
@section extensions @section extensions
@li @c extensions.dbpilots @li @c extensions.dbpilots
@li @c extensions.plugin @li @c extensions.plugin
@li @c extensions.scanner @li @c extensions.scanner
@li @c extensions.update @li @c extensions.update
@li @c extensions.olebridge - OLE automation bridge
@section Filter @section Filter
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment