1
votes

I am doing a random file access to write log records in it. Later, I do access the log based on the log number. Using the log number I do calculate the offset of the record and directly access that. The function SetFilePointerEx is used to set the current location in the file and from there I can directly read the record.

The function expects the LARGE_INTEGER as parameter. How do I use LARGE_INTEGER for the SetFilePointerEx function? The req. notes says that the program will be targeted to 64 bit OS.

1

1 Answers

4
votes

Assuming LARGE_INTEGER li;, just set li.QuadPart to the LONGLONG value you need for your file offset and use li for the offset argument in the call. Or did I miss something obvious.?

LARGE_INTEGER li, lo={0};
li.QuadPart = yourOffsetValue;

SetFilePointerEx(hFile, li, &lo, FILE_BEGIN);