[C#] 纯文本查看 复制代码 /// <summary>
/// 获取程序运行内存
/// </summary>
/// <param name="rmu_exe">exe名(不带exe)</param>
/// <returns></returns>
internal static string GetRam(string rmu_exe)
{
try
{
Process CurrentProcess = Process.GetProcessesByName(rmu_exe)[0];
PerformanceCounter pf1 = new PerformanceCounter("Process", "Working Set - Private", CurrentProcess.ProcessName);
string workingSe = String.Format("{0:F}", pf1.NextValue() / 1024 / 1024);
return $"{ workingSe }MB";
}
catch
{
string rmu_mbRam = "0 KB";
return rmu_mbRam;
}
}
获取指定进程的,在获取一下自身的文件名就好了
|