2013-04-15 21 views
0

我在www.zlib.net上看到'zlib使用示例',但他們使用stdio.h中的'fread'函數。使用Win api的Zlib createFile和ReadFile

我必須考慮我的程序的性能,所以我必須使用win api'ReadFile'函數。

但我也看到了。

This is an ugly hack required to avoid corruption of the input and output data on 
Windows/MS-DOS systems. Without this, those systems would assume that the input and 
output files are text, and try to convert the end-of-line characters from one standard 
to another. That would corrupt binary data, and in particular would render the 
compressed data unusable. This sets the input and output to binary which suppresses the 
end-of-line conversions. SET_BINARY_MODE() will be used later on stdin and stdout, at 
the beginning of main(). 

#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) 
# include <fcntl.h> 
# include <io.h> 
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) 
#else 
# define SET_BINARY_MODE(file) 
#endif 

我該怎麼做也可以在zlib上使用ReadFile?

回答

1

沒有。 ReadFile讀取二進制文件。

+0

Thx。我很愚蠢..... –