DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
OperatingSystem.cpp
Go to the documentation of this file.
1
#include "
pch.h
"
2
#include "
System/OperatingSystem.h
"
3
4
#if defined(_WIN32)
5
#include <windows.h>
6
#include "
Win32Internal.h
"
7
typedef
void (WINAPI*
RtlGetVersion_FUNC
) (OSVERSIONINFOEXW*);
8
using namespace
DotNetDupe::System::Internal
;
9
#else
10
#include <sys/utsname.h>
11
#endif
12
13
namespace
DotNetDupe
{
14
namespace
System
{
15
OperatingSystem::OperatingSystem
(
PlatformID
ePlatform,
const
Version
& vVersion)
16
: m_ePlatform(ePlatform), m_vVersion(vVersion) { }
17
18
PlatformID
OperatingSystem::GetPlatform
()
const
{
20
return
m_ePlatform;
21
}
22
23
const
Version
&
OperatingSystem::GetVersion
()
const
{
25
return
m_vVersion;
26
}
27
28
String
OperatingSystem::GetServicePack
()
const
{
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
51
String
OperatingSystem::GetVersionString
()
const
{
53
return
m_vVersion.
ToString
();
54
}
55
56
bool
OperatingSystem::IsWindows
() {
57
#if defined(_WIN32)
59
return
true
;
60
#else
61
return
false
;
62
#endif
63
}
64
65
bool
OperatingSystem::IsLinux
() {
66
#if defined(__linux__)
68
return
true
;
69
#else
70
return
false
;
71
#endif
72
}
73
74
}
75
}
RtlGetVersion_FUNC
void(WINAPI *) RtlGetVersion_FUNC(OSVERSIONINFOEXW *)
Definition
OperatingSystem.cpp:7
OperatingSystem.h
Represents information about an operating system, such as the version and platform identifier.
Win32Internal.h
DotNetDupe::System::OperatingSystem::IsWindows
static bool IsWindows()
Indicates whether the current application is running on Windows.
Definition
OperatingSystem.cpp:56
DotNetDupe::System::OperatingSystem::GetVersion
const Version & GetVersion() const
Gets a Version object that identifies the operating system.
Definition
OperatingSystem.cpp:23
DotNetDupe::System::OperatingSystem::GetVersionString
String GetVersionString() const
Gets the concatenated string representation of the platform identifier and version.
Definition
OperatingSystem.cpp:51
DotNetDupe::System::OperatingSystem::IsLinux
static bool IsLinux()
Indicates whether the current application is running on Linux.
Definition
OperatingSystem.cpp:65
DotNetDupe::System::OperatingSystem::OperatingSystem
OperatingSystem(PlatformID platform, const Version &version)
Initializes a new instance of the OperatingSystem class, using the specified platform identifier and ...
Definition
OperatingSystem.cpp:15
DotNetDupe::System::OperatingSystem::GetServicePack
String GetServicePack() const
Gets the service pack version represented by this OperatingSystem object.
Definition
OperatingSystem.cpp:28
DotNetDupe::System::OperatingSystem::GetPlatform
PlatformID GetPlatform() const
Gets a PlatformID value that identifies the operating system platform.
Definition
OperatingSystem.cpp:18
DotNetDupe::System::String
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition
String.h:74
DotNetDupe::System::String::ToString
static String ToString(int iValue)
Definition
String.cpp:643
DotNetDupe::System::String::String
String()
Initializes a new instance of the String class to an empty string.
Definition
String.cpp:64
DotNetDupe::System::Version
Represents the version number for an assembly, operating system, or component.
Definition
Version.h:21
DotNetDupe::System::Internal
Definition
Action.h:12
DotNetDupe::System::Internal::WCharToUtf8
std::string WCharToUtf8(const wchar_t *pWStr)
Definition
InternalStringConvert.h:14
DotNetDupe::System
Definition
Action.h:11
DotNetDupe::System::PlatformID
PlatformID
Identifies the operating system, or platform, supported by an assembly.
Definition
OperatingSystem.h:20
DotNetDupe
Definition
IServiceCollection.h:7
pch.h
DotNetDupe
OperatingSystem.cpp
Generated by
1.18.0