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
qsystemlibrary_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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#ifndef QSYSTEMLIBRARY_P_H
5#define QSYSTEMLIBRARY_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19#ifdef Q_OS_WIN
20# include <QtCore/qstring.h>
21# include <qt_windows.h>
22
24
26{
27public:
28 explicit QSystemLibrary(const QString &libraryName)
29 {
30 m_libraryName = libraryName;
31 }
32
33 explicit QSystemLibrary(const wchar_t *libraryName)
34 {
35 m_libraryName = QString::fromWCharArray(libraryName);
36 }
37
38 bool load(bool onlySystemDirectory = true)
39 {
40 m_handle = load((const wchar_t *)m_libraryName.utf16(), onlySystemDirectory);
41 m_didLoad = true;
42 return (m_handle != nullptr);
43 }
44
45 bool isLoaded()
46 {
47 return (m_handle != nullptr);
48 }
49
50 QFunctionPointer resolve(const char *symbol)
51 {
52 if (!m_didLoad)
53 load();
54 if (!m_handle)
55 return nullptr;
56 return QFunctionPointer(GetProcAddress(m_handle, symbol));
57 }
58
59 static QFunctionPointer resolve(const QString &libraryName, const char *symbol)
60 {
61 return QSystemLibrary(libraryName).resolve(symbol);
62 }
63
64 static Q_CORE_EXPORT HINSTANCE load(const wchar_t *lpFileName, bool onlySystemDirectory = true);
65
66private:
67 HINSTANCE m_handle = nullptr;
68 QString m_libraryName = {};
69 bool m_didLoad = false;
70};
71
73
74#endif // Q_OS_WIN
75
76#endif // QSYSTEMLIBRARY_P_H
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
Definition qstring.h:1309
p1 load("image.bmp")
Combined button and popup list for selecting options.
static const QQmlJSScope * resolve(const QQmlJSScope *current, const QStringList &names)