DWORD SetFilePointer( HANDLE hFile, // handle to file
LONG lDistanceToMove, // bytes to move pointer
PLONG lpDistanceToMoveHigh, // bytes to move pointer
DWORD dwMoveMethod // starting point);
-
dwMoveMethod
-
[in] Starting point for the file pointer move. This parameter can be one of the following values.
Value Meaning FILE_BEGIN The starting point is zero or the beginning of the file. FILE_CURRENT The starting point is the current value of the file pointer. FILE_END The starting point is the current end-of-file position.
1.可以将文件指针设置超过当前文件的大小,除非在该位置向文件写入数据或者 ,
否则不会更改文件在磁盘上的实际大小。
2.如果文件使用FILE_FLAG_NO_BUFFERING打开的,那么文件指针只能设置成扇区大小的整数倍
通过SetEndOfFile()改变文件大小 :
HANDLE Hfile = CreateFile(...);
LARGE_INTEGER liDistanceToMove;
liDistanceToMove.QuadPart = 1024;
SetFilePointerEx(hFile, liDIstanceToMove,NULL,FILE_BEGIN);
SetEndOfFile(hFile);
ClostHandle(hFile);
*GetFileType(HANDLE hDevice);查看设备类型
*BOOL GetDiskFreeSpace(。。。)点击打开链接