Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 if (SUCCEEDED(m_initResult))
32 CoUninitialize();
33}
34
45{
46#if defined(HAS_APPMODEL)
47 static const bool hasPackageIdentity = []() {
48 UINT32 length = 0;
49 switch (const auto result = GetCurrentPackageFullName(&length, nullptr)) {
50 case ERROR_INSUFFICIENT_BUFFER:
51 return true;
52 case APPMODEL_ERROR_NO_PACKAGE:
53 return false;
54 default:
55 qWarning("Failed to resolve package identity (error code %ld)", result);
56 return false;
57 }
58 }();
59 return hasPackageIdentity;
60#else
61 return false;
62#endif
63}
64
void qErrnoWarning(const char *msg,...)
Combined button and popup list for selecting options.
bool qt_win_hasPackageIdentity()
#define qWarning
Definition qlogging.h:162
GLenum GLuint GLenum GLsizei length
GLuint64EXT * result
[6]