Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qfunctions_win.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qfunctions_win_p.h"
5
6#include <QtCore/qdebug.h>
7
8#include <combaseapi.h>
9#include <objbase.h>
10
11#if __has_include(<appmodel.h>)
12# include <appmodel.h>
13# define HAS_APPMODEL
14#endif
15
17
18QComHelper::QComHelper(COINIT concurrencyModel)
19{
20 // Avoid overhead of initializing and using obsolete technology
21 concurrencyModel = COINIT(concurrencyModel | COINIT_DISABLE_OLE1DDE);
22
23 m_initResult = CoInitializeEx(nullptr, concurrencyModel);
24
25 if (FAILED(m_initResult))
26 qErrnoWarning(m_initResult, "Failed to initialize COM library");
27}
28
29QComHelper::~QComHelper()
30{
31 Q_ASSERT(m_threadId == GetCurrentThreadId());
32 if (SUCCEEDED(m_initResult))
33 CoUninitialize();
34}
35
46{
47#if defined(HAS_APPMODEL)
48 static const bool hasPackageIdentity = []() {
49 UINT32 length = 0;
50 switch (const auto result = GetCurrentPackageFullName(&length, nullptr)) {
51 case ERROR_INSUFFICIENT_BUFFER:
52 return true;
53 case APPMODEL_ERROR_NO_PACKAGE:
54 return false;
55 default:
56 qWarning("Failed to resolve package identity (error code %ld)", result);
57 return false;
58 }
59 }();
60 return hasPackageIdentity;
61#else
62 return false;
63#endif
64}
65
void qErrnoWarning(const char *msg,...)
Combined button and popup list for selecting options.
bool qt_win_hasPackageIdentity()
#define qWarning
Definition qlogging.h:166
GLenum GLuint GLenum GLsizei length
GLuint64EXT * result
[6]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47