1
Vote

GetLastError not correct for CreateDirectory and some other APIs.

description

During testing noticed that the win32 GetLastError() function was incorrrectly returning the value 2 immediately after a successful call of CreateDirectory().
After a bit of looking about in the source I noticed that the line:

SetLastError = true

was missing in the [DllImport] attribute definition for the signature of CreateDirectory(). When I added this to the [DllImport] as per GetFileAttributes() function immediately below it in the source code, GetLastError() returned zero as expected.

After a quick search also noticed the the same "
SetLastError = true" was also missing from the following functions:

SetFileAttributes
RemoveDirectory
DeleteFile
FindFirstFile
FindNextFile

Cheers
      Dave
PS. Keep up the good work

comments