Have a look at this answer.
You could rewrite the GetPerformanceData
function to allow connecting to remote registry:
function GetPerformanceData(const RegValue: string; const ComputerName: string = ''): PPerfDataBlock;
const
BufSizeInc = 4096;
var
BufSize, RetVal: Cardinal;
Key: HKEY;
begin
BufSize := BufSizeInc;
Result := AllocMem(BufSize);
try
if ComputerName = '' then
Key := HKEY_PERFORMANCE_DATA
else if RegConnectRegistry(PChar(ComputerName), HKEY_PERFORMANCE_DATA, Key) <> ERROR_SUCCESS then
RaiseLastOSError;
RetVal := RegQueryValueEx(Key, PChar(RegValue), nil, nil, PByte(Result), @BufSize);
try
repeat
case RetVal of
ERROR_SUCCESS:
Break;
ERROR_MORE_DATA:
begin
Inc(BufSize, BufSizeInc);
ReallocMem(Result, BufSize);
RetVal := RegQueryValueEx(Key, PChar(RegValue), nil, nil, PByte(Result), @BufSize);
end;
else
RaiseLastOSError;
end;
until False;
finally
RegCloseKey(Key);
end;
except
FreeMem(Result);
raise;
end;
end;
See the other functions in that unit for an example how to retrieve specific counter values from the returned performance data. Note that they were all written to work locally, so you'll need to modify them to be able to specify computer name as an additional parameter, for example:
function GetSystemUpTime(const ComputerName: string = ''): TDateTime;
const
SecsPerDay = 60 * 60 * 24;
var
Data: PPerfDataBlock;
Obj: PPerfObjectType;
Counter: PPerfCounterDefinition;
SecsStartup: UInt64;
begin
Result := 0;
Data := GetPerformanceData(IntToStr(ObjSystem), ComputerName);
try
Obj := GetObjectByNameIndex(Data, ObjSystem);
if not Assigned(Obj) then
Exit;
Counter := GetCounterByNameIndex(Obj, CtrSystemUpTime);
if not Assigned(Counter) then
Exit;
SecsStartup := GetCounterValue64(Obj, Counter);
// subtract from snapshot time and divide by base frequency and number of seconds per day
// to get a TDateTime representation
Result := (Obj^.PerfTime.QuadPart - SecsStartup) / Obj^.PerfFreq.QuadPart / SecsPerDay;
finally
FreeMem(Data);
end;
end;
You can get the perf object and counter indexes by the command lodctr /s:<filename>
.
For example, 'Pages/sec' counter index is 40 and belongs to perf object 'Memory', index 4.
Also have a look here on how to interpret raw counter data, depending on their definition.