Can I create Windows XP's Compressed (Zipped) Folder using Delphi?
相关问题
- Is there a Delphi 5 component that can handle .png
- the application was unable to start correctly 0xc0
- Is there a way to install Delphi 2010 on Windows 2
- Is TWebBrowser dependant on IE version?
- Handle button click in another application
相关文章
- Why windows 64 still makes use of user32.dll etc?
- Best way to implement MVVM bindings (View <-> V
- Can WM_NEXTDLGCTL be used with non-dialog windows?
- Windows EventLog: How fast are operations with it?
- How to force Delphi compiler to display all hints
- Coloring cell background on firemonkey stringgrid
- Are resource files compiled as UNICODE or ANSI cod
- HelpInsight documentation in Delphi 2007
According to a thread in eggheadcafe, you can use CreateFile Function with
FILE_FLAG_BACKUP_SEMANTICS
to create a Compressed Folder.For shell extensions route, take a look at Using Windows XP "Compressed Folder" shell extension to work with .zip files by Namespace Edanmo, which is written in VB.
I just found the similar question asked on C++. Take a look at Creating a ZIP file on Windows (XP/2003) in C/C++. I have a feeling the easiest route is buying ZipForge. See Zip a file in Delphi code sample.
A "zipped" folder in Windows is nothing more than a .ZIP file compressed using any standard zip library. Compressed folders are a different animal and require an NTFS disk format.
For the "Zip" file, I strongly suggest the Turbo Power Abbrevia, which is open source and works well. You might want to check this alternate site if your using Delphi 2009 as it might be a more recent copy.
If your wanting to use the compressed folders option, you will need to modify the directory flags on the directory handle. This will only impact NEW files added to that directory and will not automatically compress existing files. If you have an existing directory you are trying to compress, then rename each existing file, and load and save it back to the original name deleting the original file when complete with each one. Yozey had a good link to the MSDN documentation. Just remember that this only works with NTFS formatted disks, so you will need to add a check for that in your code.
If you are using Delphi X2, just use TZipFile from System.Zip:
To Zip a folder, use:
To Zip files, use:
Take a look at these:
Take a look at this OpenSource SynZip unit. It's even faster for decompression than the default unit shipped with Delphi, and it will generate a smaller exe (crc tables are created at startup).
No external dll is needed. Works from Delphi 6 up to XE. No problem with Unicode version of Delphi. All in a single unit.
I just made some changes to handle Unicode file names inside Zip content, not only Win-Ansi charset but any Unicode chars. Feedback is welcome.
Some time ago, I've tried all of the Delphi compression libraries that I could find, and eventually I ended up using KaZip by Kiril Antonov.
My requirements were:
I use it mainly to turn .kml files into .kmz, and it does that amazingly fast.
Here's an example of how I use it: