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);
Пример #2
0
 public static extern PdhStatus PdhCollectQueryData(PdhQueryHandle query);
Пример #3
0
 public static extern PdhStatus PdhAddEnglishCounter(
     PdhQueryHandle query,
     string path,
     IntPtr userData,
     out PdhCounter counter);
Пример #4
0
 public static extern PdhStatus PdhOpenQuery(string dataSource, IntPtr userData, out PdhQueryHandle query);
 public static PdhStatus CollectQueryData(this PdhQueryHandle query)
 => PdhExports.PdhCollectQueryData(query);