bump product version to 4.1.6.2
[LibreOffice.git] / extensions / source / ole / olethread.cxx
blob80d8c6e0393e055e137f3c8713b8c8e95d29a9ec
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "ole2uno.hxx"
22 #include <osl/thread.hxx>
24 using namespace std;
26 namespace ole_adapter
28 // CoInitializeEx *
29 typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInitEx)( LPVOID, DWORD);
30 // CoInitialize *
31 typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInit)( LPVOID);
33 void o2u_attachCurrentThread()
35 static osl::ThreadData oleThreadData;
37 if ((sal_Bool)(sal_IntPtr)oleThreadData.getData() != sal_True)
39 HINSTANCE inst= LoadLibrary( _T("ole32.dll"));
40 if( inst )
42 HRESULT hr;
43 // Try DCOM
44 ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress( inst, _T("CoInitializeEx"));
45 if( initFuncEx)
46 hr= initFuncEx( NULL, COINIT_MULTITHREADED);
47 // No DCOM, try COM
48 else
50 ptrCoInit initFunc= (ptrCoInit)GetProcAddress( inst,_T("CoInitialize"));
51 if( initFunc)
52 hr= initFunc( NULL);
55 oleThreadData.setData((void*)sal_True);
59 } // end namespace
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */