2017년 1월 11일 수요일

4GB 이상 파일 포인터 지정( SetFilePointerEx )

4GB 이상의 파일의 파일포인터를 지정할때는 SetFilePointerEx를씀

int64_t llFileSeek (HANDLE hf, __int64 distance, DWORD MoveMethod)
{
LARGE_INTEGER li;
li.QuadPart = distance;
SetFilePointerEx(hf, li, &li, MoveMethod);
if (GetLastError() != NO_ERROR)
{
  li.QuadPart = -1;
}
    return li.QuadPart;
}


SetFilePointer를 쓸대는 QuadPart를 음수로 변환해서
난 잘 안되던데 왜인지.... 댓글좀
int64_t llFileSeek (HANDLE hf, __int64 distance, DWORD MoveMethod)
{
LARGE_INTEGER li;
li.QuadPart = -distance;
SetFilePointerEx(hf, li, &li, MoveMethod);
if (GetLastError() != NO_ERROR)
{
   li.QuadPart = -1;
}
    return li.QuadPart;
}