开发者

How can I retrieve the "Minimum allowed"/"Recommended"/"Currently allocated" values of paging file size on Windows using C++?

Windows XP/Vista/7

  1. System Properties
  2. Advanced tab
  3. Settings... button under Performance
  4. Advanced tab
  5. Change... button
  6. The numbers at the bottom of that window in the "Total paging file size for all drives" section

Anybody know how I would go about getting those thr开发者_开发问答ee numbers from within a C++ program?

Thanks!


You can do some of this using WMI, the class you want is Win32_PageFileSetting. In .Net this is (more easily) accessed via System.Management. If you want runtime usage, you can use Win32_PageFileUsage.

Note the elevated privilege you require in that documentation.

I don't see any way to access the minimum and recommended values, at this point.


That information is stored in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Session Manager\Memory Managment in the PagingFiles value. It is a REG_MULTI_SZ, and each string is of the form:

PAGINGFILEPATH StartSize MaxSize

So, for example, I set my C drive to be 16384 MB for both sizes, the key data would look like:

L"C:\pagefile.sys 16384 16384\0"

NOTE2: It's possible to omit the numbers, in which case the system manages the size of the page file on the specified drive.

NOTE: The value specified there is not the value the system is currently using, but the value that will be used upon system reboot. This is because the paging file generally cannot be changed once the system is running, except to expand the paging file. So if the user would have changed the setting but not rebooted, that key would contain the settings for after reboot, not the settings currently in effect.

If you want the settings currently in effect you can check the sizes of pagefile.sys on each of the drives. That won't give you the max size but it will at least give you an idea.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜