X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0a0e6a5bafe2efb3466b1527eb7eb670aaa5e634..e53a95bcb122a06a74e116aba717b0d7a5bdc1b8:/include/wx/msw/ole/oleutils.h diff --git a/include/wx/msw/ole/oleutils.h b/include/wx/msw/ole/oleutils.h index 9dc4716278..b43624bee2 100644 --- a/include/wx/msw/ole/oleutils.h +++ b/include/wx/msw/ole/oleutils.h @@ -18,13 +18,49 @@ #include "wx/defs.h" +#if wxUSE_OLE + // get IUnknown, REFIID &c #include +#include "wx/intl.h" // ============================================================================ // 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 +241,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