Einzelnen Beitrag anzeigen

trashcandesign

Registriert seit: 21. Feb 2006
Ort: Mühlhausen
187 Beiträge
 
Delphi XE2 Professional
 
#5

Re: TPLockBox Funktionsaufruf -> Fenster wird weiß?!

  Alt 20. Apr 2007, 09:01
Hier der Quelltext:


Delphi-Quellcode:
[...]

type
  TDecodeThread = class(TThread)
  private
    { Private-Deklarationen }
  public
    FFilename: string;
    FPW: string;
  function DecodeFile(sFileName, sPassword: string): Boolean;
  protected
    procedure Execute; override;
  end;

[...]

implementation
[...]



procedure TDlgDatenTransferIntern.MPFeuerImport;
var
  DThread : TDecodeThread;
  sPassword, sFilename : string;

  [...]
begin
  [...]

  //Thread aufruf
  DThread := TDecodeThread.Create(True);
  DThread.Priority := tpNormal;
  DThread.FreeOnTerminate := True;
  DThread.FFilename := sFilename;
  DThread.FPW := sPassword;
  DThread.Resume;

  WaitForSingleObject(DThread.Handle, INFINITE);

  [...]
end;

function TDecodeThread.DecodeFile(sFileName, sPassword: string): Boolean;
var
  Blowfish : TlbBlowfish;
begin

    if FileExists(COPY(sFileName, 1, Length(sFileName)-4)+'.FDB') then
      DeleteFile(COPY(sFileName, 1, Length(sFileName)-4)+'.FDB');


    Blowfish := TlbBlowfish.Create(nil);

    Blowfish.GenerateKey(UpperCase(sPassword));

    Blowfish.DecryptFile(COPY(sFileName, 1, Length(sFileName)-4)+'.BLF', COPY(sFileName, 1, Length(sFileName)-4)+'.FDB');

    Blowfish.Free;

end;


procedure TDecodeThread.Execute;
var
  HashDecodedFile: string;
begin
  if not DecodeFile(FFilename, FPW) then
    Messagebox(Handle, 'Fehler beim Entschlüsseln der Datei.',
      'Datei entschlüsseln', MB_ICONSTOP);
end;
  Mit Zitat antworten Zitat