getCpuInfo
getCpuInfo
Info
getCpuInfo is a synchronous query function that returns CPU hardware information. It spawns the C# helper EXE which queries Win32_Processor via WMI, returning an array of CpuInfo objects.
Signature
function getCpuInfo(): CpuInfo[];Return Value
| Type | Description |
|---|---|
CpuInfo[] | Array of CPU information objects (one per physical processor) |
Warning
All properties in the returned objects may be null if the corresponding WMI property is not available on the system.
Usage
Use this function to display CPU specifications in a system information panel, hardware inventory, or diagnostic tool.
Note
This function returns static hardware specifications (model name, core count, max clock speed), not real-time metrics like current CPU usage. For real-time CPU monitoring, use getCpu() from the Performance Monitor plugin.
Tips
On most consumer systems, the returned array contains exactly one element. Multi-socket server boards may return multiple entries.
Example
import { getCpuInfo } from '@eisland/windows-hardware-info-helper';
const cpus = getCpuInfo();
if (cpus.length > 0) {
const cpu = cpus[0];
console.log(`${cpu.name}`);
console.log(`${cpu.numberOfCores} cores / ${cpu.numberOfLogicalProcessors} threads`);
console.log(`Up to ${cpu.maxClockSpeedMhz} MHz`);
}const { getCpuInfo } = require('@eisland/windows-hardware-info-helper');
const cpus = getCpuInfo();
if (cpus.length > 0) {
const cpu = cpus[0];
console.log(`${cpu.name}`);
console.log(`${cpu.numberOfCores} cores / ${cpu.numberOfLogicalProcessors} threads`);
console.log(`Up to ${cpu.maxClockSpeedMhz} MHz`);
}Notes
Note
The function synchronously spawns a child process. Typical execution time is 200-500ms. Avoid calling it in tight loops or on every frame.
Tips
Cache the result if you need to display it in multiple places — the hardware configuration does not change during a session.
Important
This function requires the .NET runtime and the built C# EXE. If the EXE is not found, the function returns an empty array [].
Danger Avoidance
Caution
Do not call getCpuInfo() in a polling loop or animation frame. Each call spawns a new process, which is expensive. Cache the result and reuse it.
Changelog
bb5b2-on

