2016-06-16 12:59:54 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-06-16 12:59:54 +00:00
|
|
|
*/
|
|
|
|
#include "platform/win/windows_dlls.h"
|
|
|
|
|
2020-07-02 17:01:25 +00:00
|
|
|
#include "base/platform/win/base_windows_safe_library.h"
|
|
|
|
|
2019-06-03 10:48:36 +00:00
|
|
|
#include <VersionHelpers.h>
|
2018-07-28 10:50:28 +00:00
|
|
|
#include <QtCore/QSysInfo>
|
|
|
|
|
2021-05-10 14:27:23 +00:00
|
|
|
#define LOAD_SYMBOL(lib, name) ::base::Platform::LoadMethod(lib, #name, name)
|
2021-04-19 15:41:14 +00:00
|
|
|
|
2021-07-20 14:10:23 +00:00
|
|
|
bool DirectXResolveCompiler();
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
namespace Platform {
|
|
|
|
namespace Dlls {
|
2021-06-30 21:15:56 +00:00
|
|
|
namespace {
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2021-06-30 21:15:56 +00:00
|
|
|
struct SafeIniter {
|
|
|
|
SafeIniter();
|
|
|
|
};
|
2016-08-14 18:55:59 +00:00
|
|
|
|
2021-06-30 21:15:56 +00:00
|
|
|
SafeIniter::SafeIniter() {
|
|
|
|
base::Platform::InitDynamicLibraries();
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2021-06-30 21:15:56 +00:00
|
|
|
const auto LibShell32 = LoadLibrary(L"shell32.dll");
|
2021-05-10 14:27:23 +00:00
|
|
|
LOAD_SYMBOL(LibShell32, SHAssocEnumHandlers);
|
|
|
|
LOAD_SYMBOL(LibShell32, SHCreateItemFromParsingName);
|
|
|
|
LOAD_SYMBOL(LibShell32, SHOpenWithDialog);
|
|
|
|
LOAD_SYMBOL(LibShell32, OpenAs_RunDLL);
|
|
|
|
LOAD_SYMBOL(LibShell32, SHQueryUserNotificationState);
|
|
|
|
LOAD_SYMBOL(LibShell32, SHChangeNotify);
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2020-07-24 12:15:32 +00:00
|
|
|
//if (IsWindows10OrGreater()) {
|
|
|
|
// static const auto kSystemVersion = QOperatingSystemVersion::current();
|
|
|
|
// static const auto kMinor = kSystemVersion.minorVersion();
|
|
|
|
// static const auto kBuild = kSystemVersion.microVersion();
|
|
|
|
// if (kMinor > 0 || (kMinor == 0 && kBuild >= 17763)) {
|
2021-09-28 17:11:35 +00:00
|
|
|
// const auto LibUxTheme = LoadLibrary(L"uxtheme.dll");
|
2020-07-24 12:15:32 +00:00
|
|
|
// if (kBuild < 18362) {
|
2021-05-10 14:27:23 +00:00
|
|
|
// LOAD_SYMBOL(LibUxTheme, AllowDarkModeForApp, 135);
|
2020-07-24 12:15:32 +00:00
|
|
|
// } else {
|
2021-05-10 14:27:23 +00:00
|
|
|
// LOAD_SYMBOL(LibUxTheme, SetPreferredAppMode, 135);
|
2020-07-24 12:15:32 +00:00
|
|
|
// }
|
2021-05-10 14:27:23 +00:00
|
|
|
// LOAD_SYMBOL(LibUxTheme, AllowDarkModeForWindow, 133);
|
|
|
|
// LOAD_SYMBOL(LibUxTheme, RefreshImmersiveColorPolicyState, 104);
|
|
|
|
// LOAD_SYMBOL(LibUxTheme, FlushMenuThemes, 136);
|
2020-07-24 12:15:32 +00:00
|
|
|
// }
|
|
|
|
//}
|
2016-08-14 22:53:47 +00:00
|
|
|
|
2021-06-30 21:15:56 +00:00
|
|
|
const auto LibPropSys = LoadLibrary(L"propsys.dll");
|
2021-06-30 15:20:49 +00:00
|
|
|
LOAD_SYMBOL(LibPropSys, PSStringFromPropertyKey);
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2021-06-30 21:15:56 +00:00
|
|
|
const auto LibPsApi = LoadLibrary(L"psapi.dll");
|
2021-05-10 14:27:23 +00:00
|
|
|
LOAD_SYMBOL(LibPsApi, GetProcessMemoryInfo);
|
2020-07-24 12:15:32 +00:00
|
|
|
|
2021-06-30 21:15:56 +00:00
|
|
|
const auto LibUser32 = LoadLibrary(L"user32.dll");
|
2021-05-10 14:27:23 +00:00
|
|
|
LOAD_SYMBOL(LibUser32, SetWindowCompositionAttribute);
|
2016-06-16 12:59:54 +00:00
|
|
|
}
|
|
|
|
|
2021-06-30 21:15:56 +00:00
|
|
|
SafeIniter kSafeIniter;
|
|
|
|
|
|
|
|
} // namespace
|
2021-07-20 14:10:23 +00:00
|
|
|
|
|
|
|
void CheckLoadedModules() {
|
|
|
|
if (DirectXResolveCompiler()) {
|
|
|
|
auto LibD3DCompiler = HMODULE();
|
|
|
|
if (GetModuleHandleEx(0, L"d3dcompiler_47.dll", &LibD3DCompiler)) {
|
|
|
|
constexpr auto kMaxPathLong = 32767;
|
|
|
|
auto path = std::array<WCHAR, kMaxPathLong + 1>{ 0 };
|
|
|
|
const auto length = GetModuleFileName(
|
|
|
|
LibD3DCompiler,
|
|
|
|
path.data(),
|
|
|
|
kMaxPathLong);
|
|
|
|
if (length > 0 && length < kMaxPathLong) {
|
|
|
|
LOG(("Using DirectX compiler '%1'."
|
|
|
|
).arg(QString::fromWCharArray(path.data())));
|
|
|
|
} else {
|
|
|
|
LOG(("Error: Could not resolve DirectX compiler path."));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LOG(("Error: Could not resolve DirectX compiler module."));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LOG(("Error: Could not resolve DirectX compiler library."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
} // namespace Dlls
|
|
|
|
} // namespace Platform
|