From b24957e81237a77b69e023e66324f13189307310 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 26 Nov 2013 14:11:23 +0100 Subject: clean up some COM initialization CoInitialize{Ex] always exist in all supported Win32 versions, so just call them. Change-Id: I45f227319aae811b6c94a3ac475467a06146b8e9 --- embedserv/source/embed/servprov.cxx | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'embedserv/source/embed') diff --git a/embedserv/source/embed/servprov.cxx b/embedserv/source/embed/servprov.cxx index 739a3088f025..93995d402fdd 100644 --- a/embedserv/source/embed/servprov.cxx +++ b/embedserv/source/embed/servprov.cxx @@ -79,31 +79,18 @@ void *CurThreadData::getData() 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() { static CurThreadData oleThreadData; if ( oleThreadData.getData() != 0 ) { - HINSTANCE inst= LoadLibrary( _T("ole32.dll")); - if( inst ) - { - HRESULT hr; - ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress( inst, _T("CoInitializeEx")); - if( initFuncEx) - hr= initFuncEx( NULL, COINIT_MULTITHREADED); - else - { - ptrCoInit initFunc= (ptrCoInit)GetProcAddress( inst,_T("CoInitialize")); - if( initFunc) - hr= initFunc( NULL); - } + HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); + if (!SUCCEEDED(hr)) + { // FIXME: is it a problem that this ends up in STA currently? + assert(RPC_E_CHANGED_MODE == hr); + SAL_INFO("embedserv.ole", + "CoInitializeEx fail: probably thread is in STA already?"); } oleThreadData.setData((void*)sal_True); } -- cgit