a:TRegistry; begin a:=TRegistry.create; a.rootkey:=HKEY_CLASSES_ROOT;
if a.openkey('Folder\Shell\cutbig',true) then begin //用writestring将设置值写入打开的主键 a.writestring('','加密/解密文件夹'); a.closekey; end; if a.openkey('Folder\Shell\cutbig\command',true) then begin //command子键的内容是点击右键后选择相应项后要运行的程序; //%1是在单击右键时选中的文件名
procedure TForm1.Button5Click(Sender: TObject); begin application.Terminate; end;
procedure TForm1.Button1Click(Sender: TObject); var password:string; begin if FilePahtName='' then begin Application.MessageBox('没有可加密的文件夹,请从文件夹上右键启动加密程序!', '系统', MB_OK + MB_ICONWARNING); Application.Terminate; end;
if (Edit1.Text='') or (Edit2.text='') then begin Application.MessageBox('密码不能为空,请输入你的密码!', '系统', MB_OK + MB_ICONWARNING); Exit; end;
if Edit2.Text=Edit1.Text then begin password:=Edit2.Text; JiaMI(FilePahtName,password); Application.MessageBox('文件夹添加密码成功,请牢记您的密码!', '系统', MB_OK + MB_ICONINFORMATION); Application.Terminate; end else begin Application.MessageBox('两次输入的密码不一致,请重新输入!', '系统', MB_OK + MB_ICONWARNING); Edit2.SetFocus; end; end;
procedure TForm1.Edit2Exit(Sender: TObject); begin if Edit2.Text<>Edit1.Text then begin Application.MessageBox('两次输入的密码不一致,请重新输入!', '系统', MB_OK + MB_ICONWARNING); Edit2.SetFocus; end; end;
procedure TForm1.FormShow(Sender: TObject); begin Edit1.SetFocus; end;
end.
program JiaMi;
uses Forms, SysUtils, main in 'main.pas' {Form1}, Unit2 in 'Unit2.pas' {Form2}; var FilePahtName:string; {$R *.res} procedure QiDong(); var i:Integer; begin for i := 1 to ParamCount do begin if LowerCase(ParamStr(i)) <> '' then begin FilePahtName:= ParamStr(i); end; end; end; var len:Integer; fileTemp:string; begin Application.Initialize; Application.CreateForm(TForm1, Form1); QiDong; len:=Length(FilePahtName); fileTemp:=Copy(FilePahtName,len,len); if fileTemp='.' then begin Application.ShowMainForm:=False;
if Edit1.Text=password then begin Form1.JieMi(FilePahtName); DeleteFile(IniPath) ; Application.MessageBox('文件夹解密成功!', '系统', MB_OK + MB_ICONINFORMATION); Application.Terminate; end else begin Application.MessageBox('您输入的密码错误,请重新输入密码!', '系统', MB_OK + MB_ICONWARNING); Edit1.SetFocus; end; end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction); begin Application.Terminate; end;