public static PdhCounter AddCounter(this PdhQueryHandle query, string category, string counter, string instance, bool throwOnError) { var path = instance == null ? CounterPathFactory.Create(category, counter) : CounterPathFactory.Create(category, counter, instance); var status = PdhExports.PdhAddEnglishCounter(query, path, IntPtr.Zero, out var pdhCounter); if (status == PdhStatus.PDH_CSTATUS_VALID_DATA) { return(pdhCounter); } if (!throwOnError) { return(default);
protected override bool ReleaseHandle() => PdhExports.PdhCloseQuery(handle) == PdhStatus.PDH_CSTATUS_VALID_DATA;
public static PdhQueryHandle OpenRealtime() { PdhExports.PdhOpenQuery(null, IntPtr.Zero, out var handle).EnsureSuccess(nameof(PdhExports.PdhOpenQuery)); return(handle); }
public static PdhStatus CollectQueryData(this PdhQueryHandle query) => PdhExports.PdhCollectQueryData(query);