extracted code calling {Ole|Co}[Un]Initialize() to wxOle[Un]Initialize() functions in oleutils.h

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-03-11 11:47:13 +00:00
parent 61ad154c01
commit 360ae33f43
2 changed files with 48 additions and 21 deletions

View File

@@ -18,6 +18,8 @@
#include "wx/defs.h"
#if wxUSE_OLE
// get IUnknown, REFIID &c
#include <ole2.h>
@@ -25,6 +27,39 @@
// General purpose functions and macros
// ============================================================================
// ----------------------------------------------------------------------------
// initialize/cleanup OLE
// ----------------------------------------------------------------------------
// call OleInitialize() or CoInitialize[Ex]() depending on the platform
//
// return true if ok, false otherwise
inline bool wxOleInitialize()
{
// we need to initialize OLE library
#ifdef __WXWINCE__
if ( FAILED(::CoInitializeEx(NULL, COINIT_MULTITHREADED)) )
#else
if ( FAILED(::OleInitialize(NULL)) )
#endif
{
wxLogError(_("Cannot initialize OLE"));
return false;
}
return true;
}
inline void wxOleUninitialize()
{
#ifdef __WXWINCE__
::CoUninitialize();
#else
::OleUninitialize();
#endif
}
// ----------------------------------------------------------------------------
// misc helper functions/macros
// ----------------------------------------------------------------------------
@@ -205,6 +240,16 @@ BSTR wxConvertStringToOle(const wxString& str);
// Convert string from BSTR to wxString
wxString wxConvertStringFromOle(BSTR bStr);
#else // !wxUSE_OLE
// ----------------------------------------------------------------------------
// stub functions to avoid #if wxUSE_OLE in the main code
// ----------------------------------------------------------------------------
inline bool wxOleInitialize() { return false; }
inline void wxOleUninitialize() { }
#endif // wxUSE_OLE/!wxUSE_OLE
#endif //_WX_OLEUTILS_H