MessageDlg at start of file

Hi,
I am working on an encryption program in Delphi 2.0. The program is able to encrypt the selected file(s) but, for instance, if the file is a .txt, once you open the encrypted version it shows you the encrypted text. But I would rather have it that the encypting program could write a small piece of code at the start of every encrypted file with say a MessageDlg saying - 'This file has been encrypted. Do you wish to decrypt now?' with mbyes, mbno and if mryes then a shell execute to the encryption program.

Any help appreciated.
Thanks,
SG
stephen_grahamAsked:
Who is Participating?
 
MadshiConnect With a Mentor Commented:
That's possible, but the encrypted files will grow by about 20 KB. If that is no problem you can simply do something like this:

project EncryptedFileHeader;

uses Windows;

begin
  if MessageBox(0, 'This file is encrypted. Do you wish to decrypt it now?', 'Encrypted file...',MB_YESNO) = IDYES then
    ShellExecute(0, nil, pchar('c:\yourPath\yourDecrypt.exe "' + ParamStr(0) + '"'), nil, nil, SW_SHORNORMAL);
end.

Now if the user starts this encrypted file and chooses "yes", then yourDecrypt.exe is started with the encrypted file as the first parameter.

Now how can you create such an encrypted file? Simple: You have to create a new exe file and save first the EncryptedFileHeader.exe in the new file and then behind it the encrypted data. Of course the extensions of the encrypted file *must* be "exe".

YourDecrypt.exe then has to accept such a file and extract the data from the combined exe+data file.

Regards, Madshi.
0
All Courses

From novice to tech pro — start learning today.