#include "windows.h" #include void Main(int argc, char** argv) { HANDLE hFile; char buffer[64000]; BOOL b; unsigned long bytes; long lastError; hFile = CreateFile(argv[1] ? argv[1] : argv[0], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); bytes = 1; SetFilePointer(hFile, 0, NULL, FILE_END); b = ReadFile(hFile, buffer, 10, &bytes, NULL); lastError = GetLastError(); printf("ReadFile:%s,%lu bytes, GetLastError:%ld\n", b ? "true" : "false", bytes, lastError); bytes = 2; b = ReadFile(hFile, buffer, 30000, &bytes, NULL); lastError = GetLastError(); printf("ReadFile:%s,%lu bytes, GetLastError:%ld\n", b ? "true" : "false", bytes, lastError); bytes = 3; b = ReadFile(hFile, buffer, 40000, &bytes, NULL); lastError = GetLastError(); printf("ReadFile:%s,%lu bytes, GetLastError:%ld\n", b ? "true" : "false", bytes, lastError); } int main(int argc, char** argv) { Main(argc, argv); return 0; }