Your test doesn't make much sense. The call to FindClose should be done after you check the result of GetLastError, since FindClose <should> change the last error to ERROR_SUCCESS if the close operation was successful.