Originally posted by bhorrobi
How can the program determine if it doesn't have permission to access a directory? Thanks
The FindFirstFile / FindNextFile APIs fill a WIN32_FIND_DATA structure pointed by lpFindFileData ). The dwFileAttributes data member of this struct contains the attributes needed by you:
Code:
typedef struct _WIN32_FIND_DATA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
TCHAR cFileName[ MAX_PATH ];
TCHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATA, *PWIN32_FIND_DATA;
On the other hand, you should check the return values of FindFirstFile / FindNextFile, in case of failure evaluate the error given by GetLastError().