windows目录查看器
// 转到按钮处理函数
#include <io.h>
void CFindFileDlg::OnBnClickedOk()
{
struct _wfinddata64_t c_file;
intptr_t hFile;
CListCtrl *pList = (CListCtrl *)GetDlgItem(IDC_FILE_LIST);
CString path;
CString str_time, str_type, str_size;
GetDlgItemText(IDC_BROWER, path);
path.Append(_T("*.*"));
if ((hFile = _wfindfirst64(path, &c_file)) == -1L)
return;
int i = 0;
int n;
pList->DeleteAllItems();
do
{
n = pList->GetItemCount();
if (!(c_file.attrib & _A_HIDDEN)) // 显示非隐藏文件
pList->InsertItem(i, c_file.name);
COleDateTime t(c_file.time_write);
str_time.Format(_T("%d/%d/%d %d:%d"), t.GetYear(), t.GetMonth(),
t.GetDay(), t.GetHour(), t.GetMinute());
pList->SetItemText(n, 1, str_time);
if (c_file.attrib & _A_SUBDIR)
pList->SetItemText(n, 2, _T("文件夹"));
else
{
CString name = c_file.name;
str_type = name.Mid(1 + name.ReverseFind(_T('.')));
pList->SetItemText(n, 2, str_type+_T("文件"));
str_size.Format(_T("%d"), c_file.size / 1024);
str_size.Append(_T("KB"));
pList->SetItemText(n, 3, str_size);
}
++i;
} while (_wfindnext64(hFile, &c_file) == 0);
_findclose(hFile);
}
效果实现