2021-03-26 11:22:55 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <shlobj.h>
|
|
|
|
|
|
|
|
#include "win32.hpp"
|
|
|
|
#include "converter.hpp"
|
|
|
|
|
|
|
|
std::optional<std::wstring> GetCurrentModulePath()
|
|
|
|
{
|
2021-02-22 09:18:53 +00:00
|
|
|
std::wstring exePath(MAX_PATH, 0);
|
2021-03-26 11:22:55 +00:00
|
|
|
auto charWritten = GetModuleFileName(nullptr, exePath.data(), exePath.size());
|
|
|
|
if (charWritten > 0)
|
|
|
|
{
|
2021-02-23 10:04:43 +00:00
|
|
|
exePath.resize(charWritten);
|
2021-02-22 09:18:53 +00:00
|
|
|
return exePath;
|
2021-03-26 11:22:55 +00:00
|
|
|
}
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<std::wstring> GetShortcutPath()
|
|
|
|
{
|
2021-02-22 09:18:53 +00:00
|
|
|
std::wstring shortcutPath(MAX_PATH, 0);
|
2021-03-26 11:22:55 +00:00
|
|
|
auto charWritten = GetEnvironmentVariable(L"APPDATA", shortcutPath.data(), shortcutPath.size());
|
|
|
|
if (charWritten > 0)
|
|
|
|
{
|
2021-02-23 10:04:43 +00:00
|
|
|
shortcutPath.resize(charWritten);
|
2021-02-22 09:18:53 +00:00
|
|
|
return shortcutPath;
|
2021-03-26 11:22:55 +00:00
|
|
|
}
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SetAppModelIDInternal(const std::wstring& aumid)
|
|
|
|
{
|
|
|
|
return SUCCEEDED(SetCurrentProcessExplicitAppUserModelID(aumid.c_str()));
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
// Not available in mingw headers, but linking works.
|
|
|
|
NTSTATUS NTAPI RtlGetVersion(PRTL_OSVERSIONINFOW);
|
|
|
|
|
|
|
|
gboolean SupportsModernNotifications()
|
|
|
|
{
|
|
|
|
RTL_OSVERSIONINFOW rovi = { 0 };
|
|
|
|
rovi.dwOSVersionInfoSize = sizeof(rovi);
|
|
|
|
if (S_OK == RtlGetVersion(&rovi))
|
|
|
|
{
|
|
|
|
return rovi.dwMajorVersion > 6;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-02-18 09:24:53 +00:00
|
|
|
gboolean SetAppModelID(const gchar* aumid)
|
2021-03-26 11:22:55 +00:00
|
|
|
{
|
2021-02-22 09:18:53 +00:00
|
|
|
auto result = sview_to_wstr(aumid);
|
2021-03-26 11:22:55 +00:00
|
|
|
if (result.empty())
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return SetAppModelIDInternal(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|