mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Use proper type to represent a path
This commit is contained in:
parent
bf8d993743
commit
8a708fd97e
2 changed files with 8 additions and 17 deletions
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <QString>
|
||||
|
||||
#include "base/pathfwd.h"
|
||||
#include "base/path.h"
|
||||
|
||||
enum class ShutdownDialogAction;
|
||||
|
||||
|
@ -87,22 +87,14 @@ namespace Utils::Misc
|
|||
QString getUserIDString();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QString windowsSystemPath();
|
||||
Path windowsSystemPath();
|
||||
|
||||
template <typename T>
|
||||
T loadWinAPI(const QString &source, const char *funcName)
|
||||
{
|
||||
QString path = windowsSystemPath();
|
||||
if (!path.endsWith(u'\\'))
|
||||
path += u'\\';
|
||||
|
||||
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));
|
||||
const QString path = (windowsSystemPath() / Path(source)).toString();
|
||||
return reinterpret_cast<T>(::GetProcAddress(::LoadLibraryW(
|
||||
path.toStdWString().c_str()), funcName));
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue