问题描述
我正在尝试编写一个 C#/.NET 应用程序来优化我们 XP 工作站的硬盘
I'm trying to write a C#/.NET application that optimizes the hard drives for our XP workstations
- 将页面文件设置为无页面文件"
- 重启
- 运行碎片整理实用程序以优化数据和应用
- 创建一个连续的页面文件
- 重新启动,从 Sysinternals 运行 pagedefrag
我真的在为#1 苦苦挣扎.我删除以下键:SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PagingFiles
I'm really struggling with #1. I delete the following key:SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PagingFiles
重新启动后,系统控制面板显示无页面文件",但 c:\pagefile.sys 仍然存在并且它正在被 SYSTEM 进程使用,因此我无法删除它,也无法优化 HD.我尝试使用 PendingFileRenamingOperations 并且它也爆炸了.我尝试使用 WMI:Win32_PageFileSetting,但这只能让您设置大小(不是零——默认为 2MB).
Upon reboot, the System Control Panel shows "No page file", but c:\pagefile.sys still exists and its in use by the SYSTEM process so I can't delete it and I can't optimize HD. I tried using PendingFileRenamingOperations and that bombs out too. I tried using WMI: Win32_PageFileSetting, but that only lets you set sizes (not zero--defaults to 2MB).
当然,如果我执行上面概述的手动步骤,它就可以工作.
Of course, if I do the manual steps outlined above, it works.
我想我需要一个 API 调用来实现这一点.
I think I need an API call to make this happen.
推荐答案
查看 Delete
或 方法:
Look at Delete
or DeleteEx methods of the Win32_PageFile
class:
该类已被弃用,但既然您在谈论 Windows XP,那么也许它当时并未被弃用.
The class has been deprecated but since you're talking about Windows XP, maybe it wasn't deprecated then.
这篇关于在 Windows XP 上,以编程方式将 Pagefile 设置为“No Paging File";在单个 c: 驱动器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!