Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 12/16/23 in all areas

  1. Uwe Raabe

    Extract from encrypted ZIP?

    While Delphi 12 supports ZIP encryption, the actual encryption algorithm has to be provided by the developer itself or a library implementing the new IZipCryptor interface. For the common PKWARE Zip 2.0 encryption (see APPNOTE.TXT) an implementation can be found in PKWAREZipCryptor.pas. The usage is shown in the following example, which extracts all files from an encrypted zip file: var bytes: TBytes; fileName: string; zipFile: TZipFile; begin zipFile := TZipFile.Create; try zipFile.Cryptor := TPKWAREZipCryptor.Create; zipFile.Password := cPassword; zipFile.Open(zipFileName, zmRead); for var I := 0 to zipfile.FileCount - 1 do begin fileName := zipFile.FileNames[I]; zipFile.Read(I, bytes); TFile.WriteAllBytes(fileName, bytes); end; zipFile.Close; finally zipFile.Free; end; end;
  2. Remy Lebeau

    How to keep hdc alive

    Why are you creating an HDC to begin with? TBitmap already has its own HDC that it manages for you. Just draw on your TBitmap whenever you need to. What are you trying to accomplish exactly by managing your own HDC manually? You don't need that 2nd step. You can't. Resizing a bitmap will destroy its old data. But TBitmap will handle copying the old data into the new memory for you. You would have had to do that yourself with a manual HDC, so better to just let TBitmap do it for you.
  3. This is arguably one of the other significant benefits of designing code with Unit Testing in mind. It encourages you to write loosely coupled (or better entirely self standing) modules.... If you are dealing with legacy code this might be the case - but that doesn't mean that it is not worth effort. If you intend to keep the code live and supported for the future it almost certainly IS worth refactoring.
×