Now do the project because the log content is too much, even to several G. Therefore, the user requires the program can automatically compress the resulting log to facilitate the save and send. This article briefly introduces Microsoft's FCI/FDI library, hoping to be helpful to everyone.
Brief introduction:
FCI (file Compression Interface) and FDI (file decompression Interface) are the development packages provided by Microsoft for compression and decompression. The biggest benefit is that the Winnt, Win2000, WinXP systems all provide the corresponding API interface. Therefore, our program does not require an additional compression library.
This article comes with routines just to show you some simpler usage, and you can tap into other, more powerful features based on the documentation that Microsoft provides.
API Introduction:
FCI/FDI API uses a large number of callback functions, the specific function of the prototype definition you can refer to the header file.
First, FCI
FCI includes 5 APIs.
Fcicreate Create FCI context
Fciaddfile Add files to cabinet
Fciflushcabinet ends the current cabinet
Fciflushfolder ends the current folder and creates a new folder
Fcidestroy destroys FCI context
HFCI Diamondapi Fcicreate (
PERF PERF,//For returning error type
pfnfcifileplaced pfnfiledest,//used when a file spans multiple cabinet
Pfnfcialloc Pfnalloc,//used to allocate and free memory.
Pfnfcifree Pfnfree,
Pfnfciopen Pfnopen,//6 Create, read and write files separately
Pfnfciread Pfnread,//close, positioning and deletion.
Pfnfciwrite Pfnwrite,
Pfnfciclose Pfnclose,
Pfnfciseek Pfnseek,
Pfnfcidelete Pfndelete,
Pfnfcigettempfile PFNFCIGTF,//for generating temporary file names
Pccab Pccab,//is a detailed description of the compressed file by a pointer to a CCAB structure
such as: size, name, path, and so on.
void FAR * PV//Return some context parameters.
);
BOOL Diamondapi Fciaddfile (
HFCI HFCI,//context created by fcicreate
Char *pszsourcefile,//compressed file
Char *pszfilename,//The name of this file in the compressed package
BOOL Fexecute,//uncompressed file execution
Pfnfcigetnextcabinet getnextcab,//is called when the next cabinet is created, ignored here
Pfnfcistatus pfnprogress,//periodic callback function to show the progress of compression.
Pfnfcigetopeninfo pfnopeninfo,//Open file return file handle and attributes
Type of Tcomp typecompress//compression
)
BOOL Diamondapi Fciflushcabinet (
HFCI HFCI,//context created by fcicreate
BOOL Fgetnextcab,//Decide whether Getnextcab is invoked
Pfnfcigetnextcabinet getnextcab,//call when cabinet full
Pfnfcistatus pfnprogress//Fciaddfile
)
BOOL Diamondapi Fciflushfolder (
HFCI HFCI,//Parameter ditto
Pfnfcigetnextcabinet Getnextcab,
Pfnfcistatus pfnprogress
)
BOOL Diamondapi Fcidestroy (
HFCI HFCI
)