Kod:
1 OpenDialog
2 Radio Button
1 Button
Kod:
procedure TForm1.Button1Click(Sender: TObject);
var
header : array [0..4] of char;
thefile : tfilestream;
Checkheader : string;
begin
OpenDialog1.Filter :='Exe Dosyası (*.exe)|*.exe';
if OpenDialog1.Execute then
begin
thefile :=tfilestream.Create(OpenDialog1.FileName , fmopenreadwrite);
if radiobutton1.Checked = true then
begin
thefile.Seek(0,sofrombeginning);
thefile.Read(header,sizeof(header));
if header[0]=chr(05) then
begin
messagebox(form1.Handle , 'Seçdiğiniz Dosya Daha Önceden Zaten Şifrelenmiş','Uyarı',mb_iconexclamation + mb_ok);
thefile.Free;
exit;
end;
thefile.Seek(0,sofrombeginning);
thefile.Write(chr(05) + chr(05) + chr(05) + chr(05),4);
thefile.Seek(-5,sofromend);
thefile.Write(header,sizeof(header));
thefile.Free;
Showmessage('Dosya Kilitlendi');
end else if radiobutton2.Checked = true then
begin
thefile.Seek(-5,sofromend);
thefile.Read(header,sizeof(header));
thefile.Seek(0,sofrombeginning);
thefile.Write(header,sizeof(header));
thefile.Free;
showmessage('Dosya Çözüldü');
end;
end;
end;