Skip to content

Commit

Permalink
获取系统和硬件信息
Browse files Browse the repository at this point in the history
  • Loading branch information
zxffffffff committed Aug 16, 2024
1 parent 30700b3 commit 74b669c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sample-tools/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class Platform
ULONG major = *(ULONG *)(sharedUserData + 0x26c);
ULONG minor = *(ULONG *)(sharedUserData + 0x270);
ULONG build = *(ULONG *)(sharedUserData + 0x260);
// Windows-10 = 10.0.19041
// Windows 10 = 10.0.19041
// Windows 11 = 10.0.22000
// GitHub windows-latest = 10.0.20348
return fmt::format("{}.{}.{}", major, minor, build);
#elif __APPLE__
char osproductversion[64]{0};
Expand All @@ -114,12 +116,14 @@ class Platform
char osversion[64]{0};
size_t osversion_size = 64;
sysctlbyname("kern.osversion", osversion, &osversion_size, nullptr, 0);
// macOS = 14.2.1(23C71)
// macOS Sonoma 14.5 = 14.5(23F79)
// GitHub macos-latest = 14.6.1(23G93)
return fmt::format("{}({})", osproductversion, osversion);
#elif __linux__
struct utsname uts;
uname(&uts);
// CentOS-7 = 3.10.0-1160.102.1.el7.x86_64
// GitHub ubuntu-latest = 6.5.0-1025-azure
return uts.release;
#endif
}
Expand Down

0 comments on commit 74b669c

Please sign in to comment.