summaryrefslogtreecommitdiff
path: root/extensions/source/ole
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-11-26 14:11:23 +0100
committerMichael Stahl <mstahl@redhat.com>2013-11-28 00:59:48 +0100
commitb24957e81237a77b69e023e66324f13189307310 (patch)
treea8a565f6b25f2f2a42425ae8ca8b15afe1109763 /extensions/source/ole
parent95759ff2c0c895442d4d41b0edec1583caaf8abd (diff)
clean up some COM initialization
CoInitialize{Ex] always exist in all supported Win32 versions, so just call them. Change-Id: I45f227319aae811b6c94a3ac475467a06146b8e9
Diffstat (limited to 'extensions/source/ole')
-rw-r--r--extensions/source/ole/olethread.cxx25
1 files changed, 6 insertions, 19 deletions
diff --git a/extensions/source/ole/olethread.cxx b/extensions/source/ole/olethread.cxx
index 80d8c6e0393e..4fa8f582ad0f 100644
--- a/extensions/source/ole/olethread.cxx
+++ b/extensions/source/ole/olethread.cxx
@@ -25,10 +25,6 @@ using namespace std;
namespace ole_adapter
{
-// CoInitializeEx *
-typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInitEx)( LPVOID, DWORD);
-// CoInitialize *
-typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInit)( LPVOID);
void o2u_attachCurrentThread()
{
@@ -36,21 +32,12 @@ void o2u_attachCurrentThread()
if ((sal_Bool)(sal_IntPtr)oleThreadData.getData() != sal_True)
{
- HINSTANCE inst= LoadLibrary( _T("ole32.dll"));
- if( inst )
- {
- HRESULT hr;
- // Try DCOM
- ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress( inst, _T("CoInitializeEx"));
- if( initFuncEx)
- hr= initFuncEx( NULL, COINIT_MULTITHREADED);
- // No DCOM, try COM
- 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("extensions.olebridge",
+ "CoInitializeEx fail: probably thread is in STA already?");
}
oleThreadData.setData((void*)sal_True);
}