File Search

Discussion in 'MFC' started by newvcproj, Aug 21, 2008.

  1. newvcproj

    newvcproj New Member

    Joined:
    Jul 31, 2008
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Hi All

    I am working on USB Project which is small project.Main task is that only showing USB Device Name ,Drive and Data. All three thing is going on the way but problem is that when i inser USB Device then Show code
    Code:
    DUMMY LINE
    when device is blank line like that
    Code:
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    .I want to remove that line.Here is my code

    Code:
    
    BOOL CUSBDlg::FileList()
    {							
    	
    
    
              //Get Logical Drives
    
              DWORD dwDrives=GetLogicalDrives();
    
     
    
              if(0==dwDrives)
    
              {
    
        //              return FALSE;
    
              }
    
     
    
              DWORD dwCount=0;
    
     
    
              char chDriveLabel='A';
    
     
    
              char szRootpath[5]={0,0,0,0,0};
    
     
    
              while(dwDrives !=0)
    
              {
    
                       if ((dwDrives & 1) != 0)
    
                       {
    
                                 sprintf(szRootpath,"%c:\\",chDriveLabel);
    
     
    
                                 //removable drive
    
                                 if(DRIVE_REMOVABLE==GetDriveType(szRootpath))
    
                                 {
    
                                          WIN32_FIND_DATA FindFileData;
    
                                          HANDLE hFind;
    
     
    
                                          //Removable dirve lable
    
                                     //   std::cout <<"Files in " << szRootpath << std::endl;
    
    									
    									
    									 m_ListCountries.AddString(szRootpath);
    
    									 m_tree.InsertItem(szRootpath);
    
    									 
    									 
                                          //* represent search all files and directories
    
                                          szRootpath[3]='*';
    
     
    
                                          hFind=FindFirstFile(szRootpath,&FindFileData);
    
     
    
                                          if (INVALID_HANDLE_VALUE == hFind) 
    
                                          {
    
                                         //          return FALSE;
    
                                          } 
    
     
       
    									 
                                          // List all the files in the directory .
    
                                          do
    
                                          {
    											
    
                                                    //ignore the sub directories
    
                                                   if (strcmp(FindFileData.cFileName,_T(".")) && strcmp(FindFileData.cFileName,_T(".."))) 
    
                                                    {
    													
    														 m_ListCountries.AddString(FindFileData.cFileName);
    													 m_tree.InsertItem(FindFileData.cFileName);
    
                                                    }
    
    											
    
                                          }while (FindNextFile(hFind, &FindFileData) != 0);
    
     
    
                                          FindClose(hFind);
    
                                 }
    
     
    
                       }
    
                       dwDrives = dwDrives >> 1;//next drive
    
                       chDriveLabel++;
    
              }
    		 
    		  return true;
    
    }
    
    
    Plz help me

    Thx's in Advance
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice