0

我在 www.zlib.net 上看到了“zlib 使用示例”,但他们使用了 stdio.h 中的“fread”函数。

我必须考虑我的程序的性能,所以我必须使用 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 我应该怎么做?

4

1 回答 1

1

没有什么。ReadFile 读取二进制文件。

于 2013-04-15T14:08:05.883 回答