I have been able to use SetFilePointerEx
just fine, when setting the position only.
SetFilePointerEx(PD, 512, @PositionVar, FILE_BEGIN);
SetFilePointerEx(PD, 0, @PositionVar, FILE_CURRENT);
Both work; I can set positions and even check m开发者_JS百科y current one. But when I set FILE_END
as per the documentation no matter what the second parameter is and whether or not I provide a pointer for the third parameter, it fails, even on a valid handle that many other operations are able to use without fail.
For example:
SetFailed := SetFilePointerEx(PD, 0, @PositionVar, FILE_END);
SetFailed := SetFilePointerEx(PD, 0, nil, FILE_END);
Whatever I put, it fails. I am working with a handle to a physical disk and it most definitely has an end. SetFilePointer
works just fine, but it's just a little more trouble than I would like.
It's not the end of the world, but whats happening.
You can't do this as you have found out. You have to seek from the beginning or current. Use DeviceIoControl to find out the size of the device.
精彩评论