XP下可能有朋友遇到过这个问题:某个硬盘分区内,所存放的文件占用的空间太多了,一重新启动电脑就会提示“硬盘空间低”,而且一定程度上也影响了启动速度。上次重新安装操作系统后,为了方便,干脆写了个小程序。
程序很简单,大家凑合着看吧。我找了半天也没找到如何上传附件,只好把代码发上来。如果下载源程序,可以到这里:
http://bbs.77169.com/read-htm-tid-179734.html
{
Author: 不长叶子的树
E-mail: xingke110@sina.com
Blog: http://blog.csdn.net/xingke
Date: 17-01-2007
}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Registry, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WinSkinStore, WinSkinData, SkinCaption;
type
TForm1 = class(TForm)
Button1: TButton;
SkinData1: TSkinData;
SkinStore1: TSkinStore;
SkinCaption1: TSkinCaption;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var myreg:TRegistry;
begin
myreg:=TRegistry.Create;
with myreg do
begin
rootkey:=HKEY_CURRENT_USER;
if openkey('Software/Microsoft/Windows/CurrentVersion/Policies/Explorer',false) and valueExists('NoLowDiskSpaceChecks') then //如果打开键成功且NoDrives存在,则进行下面操作。
begin
if readinteger('NoLowDiskSpaceChecks')=1 then
begin
Button1.Caption:='打开“磁盘空间低”提示功能';
end
else
begin
Button1.tabstop:=False;
Button1.Font.Color:=clRed;
Button1.Caption:='关闭“磁盘空间低”提示功能';
end;
myreg.CloseKey;
myreg.Free;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var myreg:TRegistry;
begin
if Button1.caption='打开“磁盘空间低”提示功能' then
begin
myreg:=TRegistry.Create;
with myreg do
begin
RootKey:=HKEY_CURRENT_USER;
if openkey('Software/Microsoft/Windows/CurrentVersion/Policies/Explorer',true) then
begin
try
WriteBool('NoLowDiskSpaceChecks',false);
Application.MessageBox('成功打开磁盘空间低提示','提示:',mb_ok);
//showmessage('成功打开磁盘空间低提示');
Button1.tabstop:=False;
Button1.Font.Color:=clRed;
Button1.Caption:='关闭“磁盘空间低”提示功能';
except
Application.MessageBox('打开磁盘空间低提示出现错误,可能操作系统不支持此项功能','提示:',mb_ok);
//showmessage('打开磁盘空间低提示出现错误,可能操作系统不支持此项功能');
end;
end
else
begin
Button1.Caption:='打开磁盘空间低提示出现错误,可能操作系统不支持此项功能';
Button1.Enabled;
end;
end;
myreg.CloseKey;
myreg.Free;
end
else
begin
myreg:=TRegistry.Create;
with myreg do
begin
RootKey:=HKEY_CURRENT_USER;
if openkey('Software/Microsoft/Windows/CurrentVersion/Policies/Explorer',true) then
begin
try
WriteBool('NoLowDiskSpaceChecks',true);
Application.MessageBox('成功关闭磁盘空间低提示','提示:',mb_ok);
//showmessage('成功打开磁盘空间低提示');
Button1.tabstop:=False;
Button1.Font.Color:=clWindowText;
Button1.Caption:='打开“磁盘空间低”提示功能';
except
Application.MessageBox('关闭磁盘空间低提示出现错误,可能操作系统不支持此项功能','提示:',mb_ok);
//showmessage('打开磁盘空间低提示出现错误,可能操作系统不支持此项功能');
end;
end
else
begin
Button1.Caption:='关闭磁盘空间低提示出现错误,可能操作系统不支持此项功能';
Button1.Enabled;
end;
end;
myreg.CloseKey;
myreg.Free;
end;
end;
end.
本文介绍了一款用Delphi编写的简单程序,用于管理Windows XP系统中磁盘空间低的提示功能。用户可以通过该程序开启或关闭磁盘空间低的警告提示,提高系统启动速度。

662

被折叠的 条评论
为什么被折叠?



