|
|
@ -37,7 +37,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <QString> |
|
|
|
#include <QString> |
|
|
|
|
|
|
|
|
|
|
|
#include "base/pathfwd.h" |
|
|
|
#include "base/path.h" |
|
|
|
|
|
|
|
|
|
|
|
enum class ShutdownDialogAction; |
|
|
|
enum class ShutdownDialogAction; |
|
|
|
|
|
|
|
|
|
|
@ -87,22 +87,14 @@ namespace Utils::Misc |
|
|
|
QString getUserIDString(); |
|
|
|
QString getUserIDString(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN |
|
|
|
#ifdef Q_OS_WIN |
|
|
|
QString windowsSystemPath(); |
|
|
|
Path windowsSystemPath(); |
|
|
|
|
|
|
|
|
|
|
|
template <typename T> |
|
|
|
template <typename T> |
|
|
|
T loadWinAPI(const QString &source, const char *funcName) |
|
|
|
T loadWinAPI(const QString &source, const char *funcName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString path = windowsSystemPath(); |
|
|
|
const QString path = (windowsSystemPath() / Path(source)).toString(); |
|
|
|
if (!path.endsWith(u'\\')) |
|
|
|
return reinterpret_cast<T>(::GetProcAddress(::LoadLibraryW( |
|
|
|
path += u'\\'; |
|
|
|
path.toStdWString().c_str()), funcName)); |
|
|
|
|
|
|
|
|
|
|
|
path += source; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto pathWchar = std::make_unique<wchar_t[]>(path.length() + 1); |
|
|
|
|
|
|
|
path.toWCharArray(pathWchar.get()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return reinterpret_cast<T>( |
|
|
|
|
|
|
|
::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif // Q_OS_WIN
|
|
|
|
#endif // Q_OS_WIN
|
|
|
|
} |
|
|
|
} |
|
|
|