Anyone has any idea?? GetFileAttributes returns 32 (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE). The file is C:\WINDOWS\system32\drivers\etc\hosts.
Thanks a lot!
Anyone has any idea?? GetFileAttributes returns 32 (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE). The file is C:\WINDOWS\system32\drivers\etc\hosts.
Thanks a lot!
http://msdn.microsoft.com/en-us/library/aa364944(VS.85).aspx
Take a look at this. Response 32 is only FILE_ATTRIBUTE_ARCHIVE. So your code is working fine.
Which of the following is your situation?
1) GetFileAttributes returns 33 (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE)
or
2) GetFileAttributes returns 32 (FILE_ATTRIBUTE_ARCHIVE)
If the hosts file does not have the read only attribute, and GetFileAttributes does not return INVALID_FILE_ATTRIBUTES then you can trust it's return value. So if the file actually doesn't have the read only attribute, then you have situation #2 above.