Without the compression tool itself, we can identify the type of compression file by its extension, whether it’s a ZIP, RAR, 7Z, etc.

And the other way is by reading some bytes of the top part of the file. Each compression tool’s type has its own signature, usually in the first some bytes, which we can see if we open the file in Hex View as image above.

As shown above, files created in ZIP format will have signature “PK…”, RAR format will begin with “Rar!..” and SevenZip (7z) will has “7z…”

Using this information, we will create a function to open a file, read some bytes, compare with above information, and produce the result.

Below the snippet, coded in Delphi XE2 (should work with other Delphi, taking care of the “string” type);

By calling CompressionType() we will have:

Using the code above, we can check other type of file eg. PDF, ACE, by first identified their signatures.

Files .jar, .xpi, .docx are some files that actually created in ZIP format.