DELPHI版文件夹加密软件源代码


本文整理自网络,侵删。

 DELPHI版文件夹加密软件源代码 
unit main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ShellAPI,inifiles, WinSkinData,registry,Des;

type
TForm1 = class(TForm)
Button1: TButton;
GroupBox1: TGroupBox;
Edit1: TEdit;
Label2: TLabel;
Label3: TLabel;
SkinData1: TSkinData;
Label1: TLabel;
Edit2: TEdit;
Button5: TButton;

procedure FormCreate(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure JiaMI(var FilePath,MiMa:string);
procedure JieMi(var DianFile:string);
procedure ZhuCeCaiDan;
procedure DelZhuCe;
procedure Button1Click(Sender: TObject);
procedure Edit2Exit(Sender: TObject);
procedure FormShow(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
FilePahtName :string;
implementation
uses Unit2;
{$R *.dfm}


procedure Tform1.JiaMI(var FilePath,MiMa:string);
var
DianFile,IniPath:string;
inifile: TInifile;

begin

DianFile:=FilePath+'..\';
iniPath:=Filepath+'\dat.ini';
inifile:=TIniFile.Create(IniPath);

inifile.WriteString('111','key',DES.EncryStrHex(MiMa,'FEIGEW'));
inifile.Free;

renamefile(FilePath,DianFile);


end;

procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;

begin


ZhuCeCaiDan;
for i := 1 to ParamCount do
begin
if LowerCase(ParamStr(i)) <> '' then begin
FilePahtName:= ParamStr(i);
end;
end;


end;

procedure TForm1.JieMi(var DianFile:string);
var
FileName,FileJD:string;
i:Integer;
begin
FileName:=DianFile+'.\';

I:=Length(FileName);

FileJD:=Copy(FileName,1,i-3);
renamefile(FileName,FileJD);


end;

procedure TForm1.ZhuCeCaiDan;
var

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是在单击右键时选中的文件名

a.writestring('','"'+Application.exeName+'" "%1"');
a.closekey;
end;
a.free;

end;

procedure TForm1.DelZhuCe;
var

a:TRegistry;
begin
a:=TRegistry.create;
a.rootkey:=HKEY_CLASSES_ROOT;
//用deletekey删除一个主键,其所包含的子键也被删除,如果已无此主键,运行删除操作不会带来别的危害
a.deletekey('Folder\Shell\cutbig');
a.free;

Application.MessageBox('成功删除系统右键菜单!', '成功', MB_OK +
MB_ICONINFORMATION);

end;

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;

Application.CreateForm(TForm2, Form2);
Form2.Show;
end;

Application.Run;

end.





unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,des;

type
TForm2 = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation
uses main,IniFiles;
{$R *.dfm}

procedure TForm2.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;

procedure TForm2.Button1Click(Sender: TObject);
var
len:Integer;
inifile: TInifile;
IniPath,password,sstemp:string;
begin
Form1.JieMi(FilePahtName);
len:=Length(FilePahtName);

sstemp:=Copy(FilePahtName,1,len-1);
iniPath:=sstemp +'\dat.ini';

inifile:=TIniFile.Create(IniPath);
password:=inifile.ReadString('111','key','');
password:=des.DecryStrhex(password,'FEIGEW');
inifile.Free;

Form1.JiaMI(sstemp,password);

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;

end.

相关阅读 >>

Delphi在64位系统下写注册表注意事项

Delphi 分解链接主域名和文件名

Delphi 把pf8bit位图变换成pf24bit位图

Delphi 将汉字翻译成拼音缩写的函数

Delphi根据url获取缓存文件的方法

Delphi 拷贝dbgrid当前行

Delphi获取文件大小

Delphi 检查自己的进程的父进程

Delphi二值图像膨胀算法

Delphi 超精简无卡顿调用dos命令输出结果

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...