转载于:http://blog.163.com/stu_shl/blog/static/599375092012423101229382/
-
HANDLE hFile=CreateFile(TEXT("text.txt"),GENERIC_READ | GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
-
if(hFile==INVALID_HANDLE_VALUE)
-
{
-
MessageBox(TEXT("创建文件失败!"));
-
return;
-
}
-
LARGE_INTEGER liDistanceToMove;
-
liDistanceToMove.QuadPart=102400000; //设置成这个大,单位字节
-
if(!SetFilePointerEx(hFile,liDistanceToMove,NULL,FILE_BEGIN))
-
{
-
MessageBox(TEXT("移动文件指针失败!"));
-
}
-
-
if(!SetEndOfFile(hFile))
-
{
-
MessageBox(TEXT("设置文件尾失败!"));
-
}
- CloseHandle(hFile);