Add get_distribution_name() and get_version() to OS

supports: LinuxBSD, Windows, macOS, iOS, Android, UWP

Co-authored-by: bruvzg
This commit is contained in:
MJacred
2022-09-16 11:14:14 +02:00
parent d1b2a191ab
commit ac9786c525
18 changed files with 218 additions and 0 deletions

View File

@ -290,6 +290,24 @@ String OS_Windows::get_name() const {
return "Windows";
}
String OS_Windows::get_distribution_name() const {
return get_name();
}
String OS_Windows::get_version() const {
typedef LONG NTSTATUS, *PNTSTATUS;
typedef NTSTATUS(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
RtlGetVersionPtr version_ptr = (RtlGetVersionPtr)GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetVersion");
if (version_ptr != nullptr) {
RTL_OSVERSIONINFOW fow = { 0 };
fow.dwOSVersionInfoSize = sizeof(fow);
if (version_ptr(&fow) == 0x00000000) {
return vformat("%d.%d.%d", (int64_t)fow.dwMajorVersion, (int64_t)fow.dwMinorVersion, (int64_t)fow.dwBuildNumber);
}
}
return "";
}
OS::DateTime OS_Windows::get_datetime(bool p_utc) const {
SYSTEMTIME systemtime;
if (p_utc) {