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"
|
|
|
|
|
2019-06-03 10:48:36 +00:00
|
|
|
#include <VersionHelpers.h>
|
2018-07-28 10:50:28 +00:00
|
|
|
#include <QtCore/QSysInfo>
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
namespace Platform {
|
|
|
|
namespace Dlls {
|
|
|
|
|
2016-08-14 18:55:59 +00:00
|
|
|
f_SetDllDirectory SetDllDirectory;
|
|
|
|
|
|
|
|
HINSTANCE LibKernel32;
|
|
|
|
|
|
|
|
void init() {
|
|
|
|
static bool inited = false;
|
|
|
|
if (inited) return;
|
|
|
|
inited = true;
|
|
|
|
|
|
|
|
LibKernel32 = LoadLibrary(L"KERNEL32.DLL");
|
|
|
|
load(LibKernel32, "SetDllDirectoryW", SetDllDirectory);
|
|
|
|
if (SetDllDirectory) {
|
|
|
|
// Remove the current directory from the DLL search order.
|
|
|
|
SetDllDirectory(L"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
f_SetWindowTheme SetWindowTheme;
|
|
|
|
f_OpenAs_RunDLL OpenAs_RunDLL;
|
|
|
|
f_SHOpenWithDialog SHOpenWithDialog;
|
|
|
|
f_SHAssocEnumHandlers SHAssocEnumHandlers;
|
|
|
|
f_SHCreateItemFromParsingName SHCreateItemFromParsingName;
|
|
|
|
f_WTSRegisterSessionNotification WTSRegisterSessionNotification;
|
|
|
|
f_WTSUnRegisterSessionNotification WTSUnRegisterSessionNotification;
|
|
|
|
f_SHQueryUserNotificationState SHQueryUserNotificationState;
|
2016-12-19 16:51:29 +00:00
|
|
|
f_SHChangeNotify SHChangeNotify;
|
2016-06-16 12:59:54 +00:00
|
|
|
f_SetCurrentProcessExplicitAppUserModelID SetCurrentProcessExplicitAppUserModelID;
|
|
|
|
f_RoGetActivationFactory RoGetActivationFactory;
|
|
|
|
f_WindowsCreateStringReference WindowsCreateStringReference;
|
|
|
|
f_WindowsDeleteString WindowsDeleteString;
|
|
|
|
f_PropVariantToString PropVariantToString;
|
2017-02-01 10:12:52 +00:00
|
|
|
f_PSStringFromPropertyKey PSStringFromPropertyKey;
|
2018-07-25 12:04:01 +00:00
|
|
|
f_DwmIsCompositionEnabled DwmIsCompositionEnabled;
|
2018-07-26 20:36:28 +00:00
|
|
|
f_RmStartSession RmStartSession;
|
|
|
|
f_RmRegisterResources RmRegisterResources;
|
|
|
|
f_RmGetList RmGetList;
|
|
|
|
f_RmShutdown RmShutdown;
|
|
|
|
f_RmEndSession RmEndSession;
|
2018-11-12 07:50:40 +00:00
|
|
|
f_GetProcessMemoryInfo GetProcessMemoryInfo;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
HINSTANCE LibUxTheme;
|
|
|
|
HINSTANCE LibShell32;
|
|
|
|
HINSTANCE LibWtsApi32;
|
|
|
|
HINSTANCE LibPropSys;
|
|
|
|
HINSTANCE LibComBase;
|
2018-07-25 12:04:01 +00:00
|
|
|
HINSTANCE LibDwmApi;
|
2018-07-26 20:36:28 +00:00
|
|
|
HINSTANCE LibRstrtMgr;
|
2018-11-12 07:50:40 +00:00
|
|
|
HINSTANCE LibPsApi;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
void start() {
|
2016-08-14 18:55:59 +00:00
|
|
|
init();
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
LibShell32 = LoadLibrary(L"SHELL32.DLL");
|
|
|
|
load(LibShell32, "SHAssocEnumHandlers", SHAssocEnumHandlers);
|
|
|
|
load(LibShell32, "SHCreateItemFromParsingName", SHCreateItemFromParsingName);
|
|
|
|
load(LibShell32, "SHOpenWithDialog", SHOpenWithDialog);
|
|
|
|
load(LibShell32, "OpenAs_RunDLLW", OpenAs_RunDLL);
|
|
|
|
load(LibShell32, "SHQueryUserNotificationState", SHQueryUserNotificationState);
|
2016-12-19 16:51:29 +00:00
|
|
|
load(LibShell32, "SHChangeNotify", SHChangeNotify);
|
2016-06-16 12:59:54 +00:00
|
|
|
load(LibShell32, "SetCurrentProcessExplicitAppUserModelID", SetCurrentProcessExplicitAppUserModelID);
|
|
|
|
|
2016-08-14 22:53:47 +00:00
|
|
|
LibUxTheme = LoadLibrary(L"UXTHEME.DLL");
|
|
|
|
load(LibUxTheme, "SetWindowTheme", SetWindowTheme);
|
|
|
|
|
2019-06-03 10:48:36 +00:00
|
|
|
if (IsWindowsVistaOrGreater()) {
|
2016-08-14 18:55:59 +00:00
|
|
|
LibWtsApi32 = LoadLibrary(L"WTSAPI32.DLL");
|
|
|
|
load(LibWtsApi32, "WTSRegisterSessionNotification", WTSRegisterSessionNotification);
|
|
|
|
load(LibWtsApi32, "WTSUnRegisterSessionNotification", WTSUnRegisterSessionNotification);
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2016-08-14 18:55:59 +00:00
|
|
|
LibPropSys = LoadLibrary(L"PROPSYS.DLL");
|
|
|
|
load(LibPropSys, "PropVariantToString", PropVariantToString);
|
2017-02-01 10:12:52 +00:00
|
|
|
load(LibPropSys, "PSStringFromPropertyKey", PSStringFromPropertyKey);
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2019-06-03 10:48:36 +00:00
|
|
|
if (IsWindows8OrGreater()) {
|
2016-08-14 18:55:59 +00:00
|
|
|
LibComBase = LoadLibrary(L"COMBASE.DLL");
|
|
|
|
load(LibComBase, "RoGetActivationFactory", RoGetActivationFactory);
|
|
|
|
load(LibComBase, "WindowsCreateStringReference", WindowsCreateStringReference);
|
|
|
|
load(LibComBase, "WindowsDeleteString", WindowsDeleteString);
|
|
|
|
}
|
2018-07-25 12:04:01 +00:00
|
|
|
|
|
|
|
LibDwmApi = LoadLibrary(L"DWMAPI.DLL");
|
|
|
|
load(LibDwmApi, "DwmIsCompositionEnabled", DwmIsCompositionEnabled);
|
2018-07-26 20:36:28 +00:00
|
|
|
|
|
|
|
LibRstrtMgr = LoadLibrary(L"RSTRTMGR.DLL");
|
|
|
|
load(LibRstrtMgr, "RmStartSession", RmStartSession);
|
|
|
|
load(LibRstrtMgr, "RmRegisterResources", RmRegisterResources);
|
|
|
|
load(LibRstrtMgr, "RmGetList", RmGetList);
|
|
|
|
load(LibRstrtMgr, "RmShutdown", RmShutdown);
|
|
|
|
load(LibRstrtMgr, "RmEndSession", RmEndSession);
|
2016-08-14 18:55:59 +00:00
|
|
|
}
|
2018-11-12 07:50:40 +00:00
|
|
|
|
|
|
|
LibPsApi = LoadLibrary(L"PSAPI.DLL");
|
|
|
|
load(LibPsApi, "GetProcessMemoryInfo", GetProcessMemoryInfo);
|
2016-06-16 12:59:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Dlls
|
|
|
|
} // namespace Platform
|