mainunit.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:2k
- unit mainunit;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls,Registry;
- type
- TForm1 = class(TForm)
- Label1: TLabel;
- Label2: TLabel;
- Button1: TButton;
- Button2: TButton;
- procedure FormCreate(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- public
- procedure CanUseTaskMgr(Value:Boolean);
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.CanUseTaskMgr(Value:Boolean);
- var
- Reg:TRegistry;
- begin
- Reg:=TRegistry.Create;
- try
- Reg.RootKey:=HKEY_CURRENT_USER;
- if Reg.OpenKey('SoftwareMicrosoftWindowsCurrentVersionPoliciesSystem', True) then
- begin
- Reg.WriteBool('DisableTaskMgr',Value);
- end;
- finally
- Reg.CloseKey;
- Reg.Free;
- end;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- var
- Reg:TRegistry;
- begin
- Reg:=TRegistry.Create;
- try
- Reg.RootKey:=HKEY_CURRENT_USER;
- if Reg.KeyExists('SoftwareMicrosoftWindowsCurrentVersionPoliciesSystem') then
- begin
- Reg.OpenKey('SoftwareMicrosoftWindowsCurrentVersionPoliciesSystem',False);
- if Reg.ValueExists('DisableTaskMgr') then
- begin
- if (Reg.ReadBool('DisableTaskMgr')) then
- begin
- Label2.Caption:='否';
- Button1.Enabled:=False;
- Button2.Enabled:=True;
- end
- else
- begin
- Label2.Caption:='是';
- Button1.Enabled:=True;
- Button2.Enabled:=False;
- end;
- end
- else
- begin
- Label2.Caption:='是';
- Button1.Enabled:=True;
- Button2.Enabled:=False;
- end;
- end
- else
- begin
- Label2.Caption:='是';
- Button1.Enabled:=True;
- Button2.Enabled:=False;
- end;
- finally
- Reg.CloseKey;
- Reg.Free;
- end;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- CanUseTaskMgr(True);
- Label2.Caption:='否';
- Button1.Enabled:=False;
- Button2.Enabled:=True;
- ShowMessage('任务管理器已经被禁止使用!');
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- CanUseTaskMgr(False);
- Label2.Caption:='是';
- Button1.Enabled:=True;
- Button2.Enabled:=False;
- ShowMessage('任务管理器已经被允许使用!');
- end;
- end.