
On 2/22/2010 10:28 AM, Nelson, Erik - 2 wrote:
eg wrote:
"If the function fails, the return value is INVALID_SET_FILE_POINTER. To get extended error information, call GetLastError."
if ( dwPtrLow == INVALID_SET_FILE_POINTER&& GetLastError() != NO_ERROR )
It seems to me that the GetLastError() call as part of the test only makes room for problems... The error test is *defined* as
dwPtrLow == INVALID_SET_FILE_POINTER
And the GetLastError() should be called only if an error is detected. In fact, if this test had been just the test against INVALID_SET_FILE_POINTER, the code would have worked correctly even without the SetLastError() clearing the error code.
You may be right as I don't see evidence in the docs of a concreted error case which contradicts this. However, I am just a little worried about the statement in the docs which say "If an error has occurred, the return value of SetFilePointer is INVALID_SET_FILE_POINTER and GetLastError returns a value other than NO_ERROR." Perhaps this is just a case of fuzzy documentation, or I am reading too much into the "...and GetLastError returns a value other than NO_ERROR".