磁盘空间低管理程序(开源代码)

本文介绍了一款用Delphi编写的简单程序,用于管理Windows XP系统中磁盘空间低的提示功能。用户可以通过该程序开启或关闭磁盘空间低的警告提示,提高系统启动速度。

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. 

{ 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.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值