This article briefly introduces Microsoft's FCI/FDI library, hoping to help you.
Introduction:
FCI (File compression Interface) and FDI (file decompression Interface) are Development kits provided by Microsoft for compression and decompression. The biggest benefit is that the system provides corresponding API interfaces in WINNT, Win2000, and WINXP. Therefore, our program does not need additional compression libraries.
API introduction:
FCI/FDI APIs use a large number of callback functions. For the prototype definition of specific functions, refer to the header file.
I. FCI
FCI includes five APIs.
Fcicreate create FCI Context
Fciaddfile Add a file to Cabinet
Fciflushcabinet ends the current Cabinet
Fciflushfolder ends the current folder and creates a new folder
Fcidestroy: Destroy FCI Context
Hfci diamondapi fcicreate (
Perf perf, // return the Error Type
Pfnfcifileplaced pfnfiledest, // when a file spans multiple Cabinet
Pfnfcialloc pfnalloc, // used to allocate and release memory.
Pfnfcifree pfnfree,
Pfnfciopen pfnopen, // process the creation, read/write, and,
Pfnfciread pfnread, // close, locate, delete, and so on.
Pfnfciwrite pfnwrite,
Pfnfciclose pfnclose,
Pfnfciseek pfnseek,
Pfnfcidelete pfndelete,
Pfnfcigettempfile pfnfcigtf, // used to generate a temporary file name
Pccab, // a detailed description of the compressed file by a ccab structure pointer
// Such as size, name, and path.
Void far * PV // return some context parameters.
);
Bool diamondapi fciaddfile (
Hfci, // context created by fcicreate
Char * pszsourcefile, // compressed file
Char * pszfilename, // name of this file in the compressed package
Bool fexecute, // whether the file is executed during decompression
Pfnfcigetnextcabinet getnextcab, // called when the next Cabinet is created, which is ignored here
Pfnfcistatus pfnprogress, // a periodic callback function that displays the compression progress.
Pfnfcigetopeninfo pfnopeninfo, // open the file and return the file handle and attributes.
Tcomp typecompress // compression type
)
Bool diamondapi fciflushcabinet (
Hfci, // context created by fcicreate
Bool fgetnextcab, // determines whether getnextcab is called
Pfnfcigetnextcabinet getnextcab, // call when cabinet is full
Pfnfcistatus pfnprogress // same as fciaddfile
)
Bool diamondapi fciflushfolder (
Hfci, // the same as above
Pfnfcigetnextcabinet getnextcab,
Pfnfcistatus pfnprogress
)
Bool diamondapi fcidestroy (
Hfci
)
Ii. FDI
FDI includes four APIs.
Fdicreate create FDI Context
Fdiiscabinet determines whether it is a cab compressed file. If yes, its attribute is returned.
Decompress fdicopy
Fdidestroy destroy FDI context hfci diamondapi fdicreate (// The parameter is similar to the FCI Parameter
Pfnalloc,
Pfnfree,
Pfnopen,
Pfnread,
Pfnwrite,
Pfnclose,
Pfnseek,
Int cputype, // CPU type, 32-bit FDI ignore this parameter
Perf perf
)
Bool diamondapi fdiiscabinet (
Hfdi, // FDI Context
Int HF, // open file handle
Pfdicabinetinfo pfdici // return some attributes of the compressed file
)
Bool far diamondapi fdicopy (
Hfdi,
Char far * pszcabinet, // name of the file to be decompressed
Char far * pszcabpath, // path of the file to be decompressed
Int flags, // reserved, must be 0
Pfnfdinotify pfnfdin, // callback function, used to handle notifications of FDI
Pfnfdidecrypt pfnfdid, // reserved, must be null
Void far * pvuser // pass the parameter to the callback function pfnfdin, which is set to null.
)
Note:
1. The library cabinet. dll used already exists when the operating system is installed.
2. One context can only be used in the thread where it is created. To use multiple threads, you must create multiple contexts.