Mega Code Archive

 
Categories / Delphi / Files
 

How to encryptdecrypt files with windows NTFS functions

Title: How to encrypt/decrypt files with windows NTFS functions function EncryptFile(lpFilename: PChar): BOOL; stdcall; external advapi32 name 'EncryptFileA'; function DecryptFile(lpFilename: PChar; dwReserved: DWORD): BOOL; stdcall; external advapi32 name 'DecryptFileA'; {....} procedure TForm1.Button1Click(Sender: TObject); begin if not EncryptFile('c:\temp') then ShowMessage('Can''t encrypt directory.'); end; procedure TForm1.Button2Click(Sender: TObject); begin if not DecryptFile('c:\temp', 0) then ShowMessage('Can''t decrypt directory.'); end;