The GetFileAttributesEx function retrieves attributes for a specified file or directory. BOOL GetFileAttributesEx( LPCTSTR lpFileName, // file or directory name GET_FILEEX_INFO_LEVELS fInfoLevelId, // attribute class LPVOID lpFileInformation // attribute information );
LPCTSTR lpFileName, // file or directory name
GET_FILEEX_INFO_LEVELS fInfoLevelId, // attribute class
LPVOID lpFileInformation // attribute information
);
GetFileAttributes(),GetFileAttributesEx()
CFileStatus fs;
CTime m_createTime;file.GetStatus(filepath,fs);
m_createTime=fs.m_ctime;
BOOL CShellDlg::ListFile(LPCTSTR szPath)
{
CFileFind ff;
CString path = szPath;
path += "\\*.*";
BOOL res = TRUE;
CWaitCursor waiter;
if(ff.FindFile(path))
{
while(res)
{
m_List.LockWindowUpdate();
res = ff.FindNextFile();
if(!ff.IsDots())
{
counter++;
CString file = ff.GetFilePath();
int i = m_List.InsertItem(0,ff.GetFileName(),
GetIconIndex(ff.GetFilePath()));
CString size;
if (ff.GetLength64() < 1024)
size.Format("%d B",ff.GetLength());
else
{
// The following weird LONGLONG casts are because VC 6.0
// doesn't implement int64 to double conversion =8-ooo
if (ff.GetLength64() < (1024*1024))
size.Format("%3.2f KB",
(LONGLONG) ff.GetLength64() / 1024.0);
else
{
if (ff.GetLength64() < (1024*1024*1024))
size.Format("%3.2f MB",
(LONGLONG) ff.GetLength64() / (1024*1024.0));
else
size.Format("%1.2f GB",
(LONGLONG) ff.GetLength64() / (1024.0*1024*1024));
}
}
m_List.SetItemText(i,1,size);
CString type = GetTypeName(ff.GetFilePath());
m_List.SetItemText(i,2,type);
CString date;
CTime time;
ff.GetCreationTime(time);
date = time.Format("%x");
m_List.SetItemText(i,3,date);
m_List.SetItemText(i,4,ff.GetFilePath());
if(ff.IsDirectory())
{
path = ff.GetFilePath();
ListFile(path);
}
m_aniIcon.SetIcon(h_aIcon[m_icon]);
m_icon++;
if(m_icon >= ICONS)
{
m_icon = 0;
}
CString sin = ff.GetRoot();
m_SearchIN.SetWindowText(sin);
m_fFiles.SetWindowText(file);
CString found;
found.Format("%u",m_List.GetItemCount());
m_Count.SetWindowText(found);
}
}
m_List.UnlockWindowUpdate();
}
return TRUE;
}
WIN32_FIND_DATA ffd;
hSearch = FindFirstFile("g:\\test.txt",&ffd);
if(hSearch==INVALID_HANDLE_VALUE)MessageBox("No Files");
else
{
SYSTEMTIME tm;
FileTimeToSystemTime(&ffd.ftCreationTime,&tm);
CString str;
str.Format("Year=%d,Month=%d,Day=%d,Hour=%d,Minute=%d,Second=%d",tm.wYear,tm.wMonth,tm.wDay,tm.wHour,tm.wMinute,tm.wSecond);
MessageBox(str);
}
m_FileAttributes=GetFileAttributes(lptFilePath);
if(!SetFileAttributes(lptFilePath,FILE_ATTRIBUTE_NORMAL))
return FALSE;
读取文件类型并将它设置成通常的类型
m_FileAttributes=GetFileAttributes(lptFilePath);
if(!SetFileAttributes(lptFilePath,FILE_ATTRIBUTE_NORMAL))
return FALSE;
读取文件类型并将它设置成通常的类型
m_FileAttributes=GetFileAttributes(lptFilePath);
if(!SetFileAttributes(lptFilePath,FILE_ATTRIBUTE_NORMAL))
return FALSE;
读取文件类型并将它设置成通常的类型