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