Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2020-2022 The OSHI Project Contributors
* SPDX-License-Identifier: MIT
*/
package oshi.driver.windows.registry;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sun.jna.platform.win32.WinBase;
import oshi.annotation.concurrent.Immutable;
import oshi.annotation.concurrent.ThreadSafe;
import oshi.driver.windows.perfmon.ProcessInformation;
import oshi.driver.windows.perfmon.ProcessInformation.ProcessPerformanceProperty;
import oshi.util.GlobalConfig;
import oshi.util.tuples.Pair;
import oshi.util.tuples.Triplet;
/**
* Utility to read process data from HKEY_PERFORMANCE_DATA information with backup from Performance Counters or WMI
*/
@ThreadSafe
public final class ProcessPerformanceData {
private static final String PROCESS = "Process";
private static final boolean PERFDATA = GlobalConfig.get(GlobalConfig.OSHI_OS_WINDOWS_HKEYPERFDATA, true);
private ProcessPerformanceData() {
}
/**
* Query the registry for process performance counters
*
* @param pids An optional collection of process IDs to filter the list to. May be null for no filtering.
* @return A map with Process ID as the key and a {@link PerfCounterBlock} object populated with performance counter
* information if successful, or null otherwise.
*/
public static Map buildProcessMapFromRegistry(Collection pids) {
// Grab the data from the registry.
Triplet>, Long, Long> processData = null;
if (PERFDATA) {
processData = HkeyPerformanceDataUtil.readPerfDataFromRegistry(PROCESS, ProcessPerformanceProperty.class);
}
if (processData == null) {
return null;
}
List