获取驱动器的页面文件大小 [英] Get the pagefile size of a drive

查看:83
本文介绍了获取驱动器的页面文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到驱动器的当前页面文件大小?

How can I find the current pagefile size of a drive?

在Windows 7之前,在System32文件夹中曾经有一个名为pafefileconfig.vba的脚本可以使用.但现在已删除.

Priror to windows 7, There used to be a script named pafefileconfig.vba in System32 folder which can be used. But its now removed.

是否可以使用JNA来获取详细信息?如果是,怎么办?

Is it possible to get the details using JNA? If yes, how?

编辑

这是我编写的使用JNA获取页面文件信息的代码:

This is the code i wrote to get the pagefile info using JNA:

  Kernel32 kernel32 = (Kernel32)Native.loadLibrary("kernel32", Kernel32.class);
    MEMORYSTATUSEX memInfo = new MEMORYSTATUSEX();
    kernel32.GlobalMemoryStatusEx(memInfo);
    int toMB = (1024*1024);
    float RAM = memInfo.ullTotalPhys.floatValue();
    float totalPage = memInfo.ullTotalPageFile.floatValue();
    float availPage = memInfo.ullAvailPageFile.floatValue();
    float availRam = memInfo.ullAvailPhys.floatValue();

    System.out.println(memInfo.dwMemoryLoad);
    System.out.println("RAM "+RAM/toMB);
    System.out.println("RAM avail "+availRam/toMB);
    float ramUsed = RAM-availRam;
    System.out.println("RAM used "+ramUsed/toMB);
    System.out.println("Total page(RAM+Page) "+(totalPage)/toMB);
    float totalPageWithoutRam = totalPage-RAM;
    System.out.println("Total page(without RAM) "+(totalPageWithoutRam)/toMB);
    System.out.println("Total avail page(With free ram) "+availPage/toMB);
    float avialPageWithoutRam = availPage-availRam;
    System.out.println("Total page avail(Without ram) "+(avialPageWithoutRam)/toMB);
    System.out.println("Page used so far(Without ram) "+(totalPageWithoutRam-avialPageWithoutRam)/toMB);

这是输出:

82
RAM 12285.582
RAM avail 2167.6758
RAM used 10117.906
Total page(RAM+Page) 24569.348
Total page(without RAM) 12283.766
Total avail page(With free ram) 12115.641
Total page avail(Without ram) 9947.965
Page used so far(Without ram) 2335.8008

使用但这看起来与运行 wmic页面文件

wmic:root\cli>pagefile list /format :list


AllocatedBaseSize=12285
CurrentUsage=843
Description=C:\pagefile.sys
InstallDate=20120329043502.876449+330
Name=C:\pagefile.sys
PeakUsage=843
Status=
TempPageFile=FALSE

为什么我看到了区别?

推荐答案

通过WMI公开信息,您可以使用wmic命令行工具列出页面文件信息.

Well the information is exposed through WMI, you can use the wmic command line tool to list the pagefile information.

例如在我的桌面上:

C:\WINDOWS\system32>wmic pagefile list /format:list


AllocatedBaseSize=3840
CurrentUsage=213
Description=C:\pagefile.sys
InstallDate=20110616154020.168800+060
Name=C:\pagefile.sys
PeakUsage=231
Status=
TempPageFile=FALSE

您可以使用ProcessBuilder等将其集成...

You could integrate it using ProcessBuilder, etc...

根据要求,这公开了 Win32_PageFileUsage 结构,以MB为单位定义大小.

As it was asked, this is exposing the Win32_PageFileUsage structure, which defines the sizes in MB.

这篇关于获取驱动器的页面文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆