summaryrefslogtreecommitdiffhomepage
path: root/compat/win32-com.cpp
blob: 689e1411320c2be75b9a5852bc69d00095bb48f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifdef _WIN32

#include "win32-com.hpp"

#include "compat/util.hpp"

#include <QString>
#include <QThread>
#include <QDebug>

bool OPENTRACK_COMPAT_EXPORT init_com_threading(com_type t)
{
    HRESULT ret = CoInitializeEx(0, t);

    if (ret != S_OK && ret != S_FALSE)
    {
        qDebug() << "CoInitializeEx failed" << (progn (
                                                     switch (ret)
                                                     {
                                                         case RPC_E_CHANGED_MODE:
                                                            return QStringLiteral("COM threading mode already set");
                                                         default:
                                                            return QStringLiteral("Unknown error ") + QString::number(long(ret));
                                                     }
                                                     ));
        return false;
    }

    return true;
}
#endif