wxCoInitializer class added
This commit is contained in:
parent
098d14139f
commit
d390a2b4ba
@ -21,6 +21,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\src\appbar.cpp" />
|
<ClCompile Include="..\src\appbar.cpp" />
|
||||||
<ClCompile Include="..\src\appex.cpp" />
|
<ClCompile Include="..\src\appex.cpp" />
|
||||||
|
<ClCompile Include="..\src\comutils.cpp" />
|
||||||
<ClCompile Include="..\src\stdafx.cpp">
|
<ClCompile Include="..\src\stdafx.cpp">
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
@ -32,6 +33,7 @@
|
|||||||
<ClInclude Include="..\include\wxex\appbar.h" />
|
<ClInclude Include="..\include\wxex\appbar.h" />
|
||||||
<ClInclude Include="..\include\wxex\appex.h" />
|
<ClInclude Include="..\include\wxex\appex.h" />
|
||||||
<ClInclude Include="..\include\wxex\common.h" />
|
<ClInclude Include="..\include\wxex\common.h" />
|
||||||
|
<ClInclude Include="..\include\wxex\comutils.h" />
|
||||||
<ClInclude Include="..\src\stdafx.h" />
|
<ClInclude Include="..\src\stdafx.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
<ClCompile Include="..\src\appex.cpp">
|
<ClCompile Include="..\src\appex.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\comutils.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\src\stdafx.h">
|
<ClInclude Include="..\src\stdafx.h">
|
||||||
@ -42,6 +45,9 @@
|
|||||||
<ClInclude Include="..\include\wxex\appex.h">
|
<ClInclude Include="..\include\wxex\appex.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\include\wxex\comutils.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\locale\wxExtend.pot">
|
<None Include="..\locale\wxExtend.pot">
|
||||||
|
63
include/wxex/comutils.h
Normal file
63
include/wxex/comutils.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 Amebis
|
||||||
|
|
||||||
|
This file is part of wxExtend.
|
||||||
|
|
||||||
|
wxExtend is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
wxExtend is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with wxExtend. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Create an object of this class on stack to initialize/cleanup the COM automatically.
|
||||||
|
///
|
||||||
|
class ZRCOLA_API wxCoInitializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Initialize the COM
|
||||||
|
///
|
||||||
|
/// \param[in] dwCoInit The concurrency model and initialization options for the thread to pass to \c CoInitializeEx
|
||||||
|
///
|
||||||
|
wxCoInitializer(DWORD dwCoInit = COINIT_MULTITHREADED);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Dtor clean up
|
||||||
|
///
|
||||||
|
virtual ~wxCoInitializer();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Has the initialization been successful? (explicit test)
|
||||||
|
///
|
||||||
|
/// \returns
|
||||||
|
/// - true if initialization succeeded
|
||||||
|
/// - false otherwise
|
||||||
|
///
|
||||||
|
bool IsOk() const { return m_ok; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Has the initialization been successful? (implicit test)
|
||||||
|
///
|
||||||
|
/// \returns
|
||||||
|
/// - true if initialization succeeded
|
||||||
|
/// - false otherwise
|
||||||
|
///
|
||||||
|
operator bool() const { return m_ok; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_ok;
|
||||||
|
};
|
37
src/comutils.cpp
Normal file
37
src/comutils.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015-2016 Amebis
|
||||||
|
|
||||||
|
This file is part of wxExtend.
|
||||||
|
|
||||||
|
wxExtend is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
wxExtend is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with wxExtend. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// wxCoInitializer
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
wxCoInitializer::wxCoInitializer(DWORD dwCoInit)
|
||||||
|
{
|
||||||
|
m_ok = SUCCEEDED(::CoInitializeEx(NULL, dwCoInit));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxCoInitializer::~wxCoInitializer()
|
||||||
|
{
|
||||||
|
if (m_ok)
|
||||||
|
::CoUninitialize();
|
||||||
|
}
|
@ -25,5 +25,6 @@
|
|||||||
|
|
||||||
#include "../include/wxex/appbar.h"
|
#include "../include/wxex/appbar.h"
|
||||||
#include "../include/wxex/appex.h"
|
#include "../include/wxex/appex.h"
|
||||||
|
#include "../include/wxex/comutils.h"
|
||||||
|
|
||||||
#include "../include/wxex/common.h"
|
#include "../include/wxex/common.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user