VC++ 如何 获取 C:\1 文件夹里 *bmp文件的个数?
2013-05-20
展开全部
void CScriptTestDlg::OnFindcurrpath()
{
// TODO: Add your control notification handler code here
BROWSEINFO bi;
char buffer[256];
ZeroMemory(buffer,256);
bi.hwndOwner=GetSafeHwnd();
bi.pidlRoot=NULL;
bi.pszDisplayName=buffer;
bi.lpszTitle="aa";
bi.ulFlags=BIF_EDITBOX;
bi.lpfn=NULL;
bi.lParam=0;
bi.iImage=0;
LPITEMIDLIST pList=NULL;
((CComboBox*)GetDlgItem(IDC_FILELIST))->ResetContent();
/*if((pList=SHBrowseForFolder(&bi))!=NULL)
{*/
char path[256];
memset(path,0,256);
//SHGetPathFromIDList(pList,path);
memcpy(path,".\\Default\\",strlen(".\\Default\\"));
CString strPath=path;
CString strtemp;
if(strPath.Right(1)!="\\")
{
strtemp.Format("%s\\*.txt",strPath);//这里是过虑文件
}
else
{
strtemp.Format("%s*.txt",strPath);
}
CFileFind findfile;
BOOL bfind=findfile.FindFile(strtemp);
while (bfind)
{
bfind=findfile.FindNextFile();
((CComboBox*)GetDlgItem(IDC_FILELIST))->AddString(findfile.GetFileName());
}
((CComboBox*)GetDlgItem(IDC_FILELIST))->SetCurSel(0);
//}
}
{
// TODO: Add your control notification handler code here
BROWSEINFO bi;
char buffer[256];
ZeroMemory(buffer,256);
bi.hwndOwner=GetSafeHwnd();
bi.pidlRoot=NULL;
bi.pszDisplayName=buffer;
bi.lpszTitle="aa";
bi.ulFlags=BIF_EDITBOX;
bi.lpfn=NULL;
bi.lParam=0;
bi.iImage=0;
LPITEMIDLIST pList=NULL;
((CComboBox*)GetDlgItem(IDC_FILELIST))->ResetContent();
/*if((pList=SHBrowseForFolder(&bi))!=NULL)
{*/
char path[256];
memset(path,0,256);
//SHGetPathFromIDList(pList,path);
memcpy(path,".\\Default\\",strlen(".\\Default\\"));
CString strPath=path;
CString strtemp;
if(strPath.Right(1)!="\\")
{
strtemp.Format("%s\\*.txt",strPath);//这里是过虑文件
}
else
{
strtemp.Format("%s*.txt",strPath);
}
CFileFind findfile;
BOOL bfind=findfile.FindFile(strtemp);
while (bfind)
{
bfind=findfile.FindNextFile();
((CComboBox*)GetDlgItem(IDC_FILELIST))->AddString(findfile.GetFileName());
}
((CComboBox*)GetDlgItem(IDC_FILELIST))->SetCurSel(0);
//}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询