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);
public static extern PdhStatus PdhCollectQueryData(PdhQueryHandle query);
public static extern PdhStatus PdhAddEnglishCounter( PdhQueryHandle query, string path, IntPtr userData, out PdhCounter counter);
public static extern PdhStatus PdhOpenQuery(string dataSource, IntPtr userData, out PdhQueryHandle query);
public static PdhStatus CollectQueryData(this PdhQueryHandle query) => PdhExports.PdhCollectQueryData(query);