MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_win32_com_using.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_WIN32_COM_USING_H_1616885268
12#define INCGUARD_MGL_WIN32_COM_USING_H_1616885268
13
14#include <mgl/mgl_environment.h>
15#if defined(MGL_TARGET_WIN32)
16
17#include <Windows.h>
18
19namespace MGL::Win32
20{
23{
24public:
25 /* ------------------------------------------------------------------------- */
30 /* ------------------------------------------------------------------------- */
31 ComUsing(COINIT initMode = COINIT_APARTMENTTHREADED) noexcept
32 : _isValid(false)
33 {
34 auto hr = CoInitializeEx(nullptr, initMode);
35 if ((hr == S_OK) || (hr == S_FALSE))
36 {
37 _isValid = true;
38 }
39 }
40
41 /* ------------------------------------------------------------------------- */
45 /* ------------------------------------------------------------------------- */
46 ~ComUsing() noexcept
47 {
48 if (_isValid)
49 {
50 CoUninitialize();
51 _isValid = false;
52 }
53 }
54
55 /* ------------------------------------------------------------------------- */
61 /* ------------------------------------------------------------------------- */
62 bool IsValid() noexcept
63 {
64 return _isValid;
65 }
66
67private:
68 bool _isValid;
69};
70}
71
72#endif // MGL_TARGET_WIN32
73#endif // INCGUARD_MGL_WIN32_COM_USING_H_1616885268
74
75// vim: et ts=4 sw=4 sts=4
COMを使用するためのオブジェクト
Definition mgl_win32_com_using.h:23
~ComUsing() noexcept
デストラクタ
Definition mgl_win32_com_using.h:46
ComUsing(COINIT initMode=COINIT_APARTMENTTHREADED) noexcept
コンストラクタ
Definition mgl_win32_com_using.h:31
bool IsValid() noexcept
COMが利用可能かを取得
Definition mgl_win32_com_using.h:62
MGL 環境定義