DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
OperatingSystem.cpp
Go to the documentation of this file.
1#include "pch.h"
3
4#if defined(_WIN32)
5#include <windows.h>
6#include "Win32Internal.h"
7typedef void (WINAPI* RtlGetVersion_FUNC) (OSVERSIONINFOEXW*);
8using namespace DotNetDupe::System::Internal;
9#else
10#include <sys/utsname.h>
11#endif
12
13namespace DotNetDupe {
14 namespace System {
16 : m_ePlatform(ePlatform), m_vVersion(vVersion) { }
17
20 return m_ePlatform;
21 }
22
25 return m_vVersion;
26 }
27
29#if defined(_WIN32)
31 OSVERSIONINFOEXW info;
32 ZeroMemory(&info, sizeof(OSVERSIONINFOEXW));
33 info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
34
35 HMODULE pModule = GetModuleHandleW(L"ntdll.dll");
36 if (pModule) {
37 RtlGetVersion_FUNC pRtlGetVersion = (RtlGetVersion_FUNC)GetProcAddress(pModule, "RtlGetVersion");
38 if (pRtlGetVersion) {
39 pRtlGetVersion(&info);
40 }
41 }
42
44 return String(WCharToUtf8(info.szCSDVersion).c_str());
45#else
47 return String("");
48#endif
49 }
50
53 return m_vVersion.ToString();
54 }
55
57#if defined(_WIN32)
59 return true;
60#else
61 return false;
62#endif
63 }
64
66#if defined(__linux__)
68 return true;
69#else
70 return false;
71#endif
72 }
73
74 }
75}
void(WINAPI *) RtlGetVersion_FUNC(OSVERSIONINFOEXW *)
Represents information about an operating system, such as the version and platform identifier.
static bool IsWindows()
Indicates whether the current application is running on Windows.
const Version & GetVersion() const
Gets a Version object that identifies the operating system.
String GetVersionString() const
Gets the concatenated string representation of the platform identifier and version.
static bool IsLinux()
Indicates whether the current application is running on Linux.
OperatingSystem(PlatformID platform, const Version &version)
Initializes a new instance of the OperatingSystem class, using the specified platform identifier and ...
String GetServicePack() const
Gets the service pack version represented by this OperatingSystem object.
PlatformID GetPlatform() const
Gets a PlatformID value that identifies the operating system platform.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
static String ToString(int iValue)
Definition String.cpp:643
String()
Initializes a new instance of the String class to an empty string.
Definition String.cpp:64
Represents the version number for an assembly, operating system, or component.
Definition Version.h:21
std::string WCharToUtf8(const wchar_t *pWStr)
PlatformID
Identifies the operating system, or platform, supported by an assembly.