generalize GetShortcutPath into GetEnv
This commit is contained in:
parent
2eb1eea06e
commit
fb754b0d43
|
@ -31,7 +31,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
std::wstring GetExePath();
|
std::wstring GetExePath();
|
||||||
std::wstring GetShortcutPath();
|
std::wstring GetEnv(const wchar_t *variable_name);
|
||||||
|
|
||||||
#define EXTERN extern "C"
|
#define EXTERN extern "C"
|
||||||
#define NOEXCEPT noexcept
|
#define NOEXCEPT noexcept
|
||||||
|
|
|
@ -134,9 +134,8 @@ bool ImplEnsureAumiddedShortcutExists(const char *const aumid)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto exePath = GetExePath();
|
auto exePath = GetExePath();
|
||||||
auto shortcutPath = GetShortcutPath();
|
|
||||||
|
|
||||||
auto path = shortcutPath + LR"(\Microsoft\Windows\Start Menu\Programs\Dino.lnk)";
|
auto path = GetEnv(L"APPDATA") + LR"(\Microsoft\Windows\Start Menu\Programs\Dino.lnk)";
|
||||||
if (!std::filesystem::exists(path))
|
if (!std::filesystem::exists(path))
|
||||||
{
|
{
|
||||||
return SUCCEEDED(InstallShortcut(exePath, waumid, path));
|
return SUCCEEDED(InstallShortcut(exePath, waumid, path));
|
||||||
|
|
|
@ -21,10 +21,10 @@ std::wstring GetExePath()
|
||||||
throw win32_error{};
|
throw win32_error{};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring GetShortcutPath()
|
std::wstring GetEnv(const wchar_t *const variable_name)
|
||||||
{
|
{
|
||||||
std::wstring shortcutPath(MAX_PATH, 0);
|
std::wstring shortcutPath(MAX_PATH, 0);
|
||||||
auto charWritten = GetEnvironmentVariable(L"APPDATA", shortcutPath.data(), shortcutPath.size());
|
auto charWritten = GetEnvironmentVariable(variable_name, shortcutPath.data(), shortcutPath.size());
|
||||||
if (charWritten > 0)
|
if (charWritten > 0)
|
||||||
{
|
{
|
||||||
shortcutPath.resize(charWritten);
|
shortcutPath.resize(charWritten);
|
||||||
|
|
Loading…
Reference in a new issue