18#if defined(__BORLANDC__)
33 static const SYSTEM_INFO& GetSystemInfo_()
37 static SYSTEM_INFO Init()
40 ::GetNativeSystemInfo(&s);
44 static SYSTEM_INFO systemInfo = TLocal::Init();
62 static auto productType = []
64 auto p = DWORD{PRODUCT_UNDEFINED};
113 static const auto is64Bit = []
115 auto is64Bit = BOOL{FALSE};
116 const auto r = IsWow64Process(::GetCurrentProcess(), &is64Bit);
117 WARN(!r,
_T(
"IsWow64Process failed. LastError: ") << GetLastError());
InUse(r);
120 return is64Bit != FALSE;
133 return static_cast<int>(GetSystemInfo_().dwNumberOfProcessors);
143 return GetSystemInfo_().wProcessorArchitecture;
153 typedef std::map<uint, tstring> TMap;
154 typedef TMap::value_type T;
157 T(PROCESSOR_ARCHITECTURE_INTEL,
_T(
"IA-32 (x86)")),
158 T(PROCESSOR_ARCHITECTURE_MIPS,
_T(
"MIPS")),
159 T(PROCESSOR_ARCHITECTURE_ALPHA,
_T(
"Alpha")),
160 T(PROCESSOR_ARCHITECTURE_PPC,
_T(
"PPC")),
161 T(PROCESSOR_ARCHITECTURE_SHX,
_T(
"SHX")),
162 T(PROCESSOR_ARCHITECTURE_ARM,
_T(
"ARM")),
163 T(PROCESSOR_ARCHITECTURE_IA64,
_T(
"IA-64")),
164 T(PROCESSOR_ARCHITECTURE_ALPHA64,
_T(
"Alpha64")),
165 T(PROCESSOR_ARCHITECTURE_MSIL,
_T(
"MSIL")),
166 T(PROCESSOR_ARCHITECTURE_AMD64,
_T(
"AMD64 (x86-64)")),
167 T(PROCESSOR_ARCHITECTURE_IA32_ON_WIN64,
_T(
"IA-32 on IA-64"))
169 static const TMap m(i, i +
COUNTOF(i));
170 TMap::const_iterator r = m.find(architecture);
171 return r == m.end() ?
tstring() : r->second;
180 return processorInfo;
193 template <
class TReturn>
194 auto GetCpuInfo_(
int cpuIndex, LPCTSTR value) -> TReturn
196 const auto keyName =
_T(
"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\") +
to_tstring(cpuIndex);
198 return k ? k->GetValueOrDefault(value, TReturn{}) : TReturn{};
201 int GetCpuFrequency_(
int cpuIndex)
203 return static_cast<int>(GetCpuInfo_<uint32>(cpuIndex,
_T(
"~MHz")));
206 auto GetCpuNameString_(
int cpuIndex) ->
tstring
208 return GetCpuInfo_<tstring>(cpuIndex,
_T(
"ProcessorNameString"));
211 auto GetCpuVendorIdentifier_(
int cpuIndex) ->
tstring
213 return GetCpuInfo_<tstring>(cpuIndex,
_T(
"VendorIdentifier"));
216 auto GetCpuIdentifier_(
int cpuIndex) ->
tstring
218 return GetCpuInfo_<tstring>(cpuIndex,
_T(
"Identifier"));
226struct TSystem::TProcessorInfo::TImpl
233 TImpl(
int cpuIndex = 0)
234 : Name(GetCpuNameString_(cpuIndex)),
235 VendorId(GetCpuVendorIdentifier_(cpuIndex)),
236 Identifier(GetCpuIdentifier_(cpuIndex)),
237 Frequency(GetCpuFrequency_(cpuIndex))
261 return Pimpl->VendorId;
266 return Pimpl->Identifier;
275 typedef std::map<tstring, tstring> TMap;
276 typedef TMap::value_type T;
279 T(
_T(
"AuthenticAMD"),
_T(
"AMD")),
280 T(
_T(
"GenuineIntel"),
_T(
"Intel")),
281 T(
_T(
"CyrixInstead"),
_T(
"Cyrix")),
282 T(
_T(
"CentaurHauls"),
_T(
"Centaur")),
283 T(
_T(
"RiseRiseRise"),
_T(
"Rise")),
284 T(
_T(
"GenuineTMx86"),
_T(
"Transmeta")),
285 T(
_T(
"UMC UMC UMC "),
_T(
"UMC"))
287 static const TMap m(i, i +
COUNTOF(i));
288 TMap::const_iterator r = m.find(vendorId);
289 return r == m.end() ?
tstring() : r->second;
298 return Pimpl->Frequency;
303 return IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE) != FALSE;
308 return IsProcessorFeaturePresent(PF_3DNOW_INSTRUCTIONS_AVAILABLE) != FALSE;
313 return IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE) != FALSE;
318 return IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE) != FALSE;
323 return IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE) != FALSE;
#define WARN(condition, message)
TModuleVersionInfo provides access to a TModule's VERSIONINFO resource.
static auto GetLocalMachine() -> TRegKey &
Special predefined root key defining the physical state of the computer (HKEY_LOCAL_MACHINE).
Encapsulates information about a processor core.
int GetNominalFrequency() const
Returns the frequency of CPU 0 as reported by the Windows Registry ("CentralProcessor/0/~MHz").
TProcessorInfo()
Queries CPU info and initializes members.
static tstring GetVendorName(const tstring &vendorId)
Returns the name of the CPU vendor.
tstring GetVendorId() const
auto GetIdentifier() const -> tstring
static uint GetBuildNumber()
static bool IsWin64Bit()
Returns true if the OS is 64-bit.
static int GetNumberOfProcessors()
Returns the value of the SYSTEM_INFO::dwNumberOfProcessors field returned by GetSystemInfo.
static auto GetVersionStr() -> tstring
static uint GetMinorVersion()
static uint GetProcessorArchitecture()
Returns the value of the SYSTEM_INFO::wProcessorArchitecture field returned by GetSystemInfo.
static uint GetMajorVersion()
static tstring GetProcessorArchitectureName(uint architecture)
Returns the description string for the given processor architecture.
static auto GetVersionInfo() -> TModuleVersionInfo &
Returns the product version for "kernel32.dll".
static const TProcessorInfo & GetProcessorInfo()
Returns info for the current processor.
static uint GetProductInfo()
Retrieves the product edition for the operating system on the local computer, and maps the type to th...
Definition of class TModule.
Object Windows Library (OWLNext Core).
void InUse(const T &arg)
Handy utility to avoid compiler warnings about unused parameters.
auto to_tstring(const T &v) -> tstring
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
General Registry access & registration implementation TRegKey, TRegValue, TRegKeyIterator,...
Definition of TSystem, a system information provider class.