Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC enlisting local drives

MFC enlisting local drives

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    missnazar
    wrote on last edited by
    #1

    Hi, I want to enlist local drives with their icons in the combobox . How can I do that? Drushti

    T 1 Reply Last reply
    0
    • M missnazar

      Hi, I want to enlist local drives with their icons in the combobox . How can I do that? Drushti

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      Hello Madame Nazar I think this little piece of code can help you [code] CString CNMPDrivesClass::NMPChangeToBinary(DWORD dwVar) { long j=(long)dwVar; int i,k=0; char Binary[20]; CString str; str.Format("%d",j); while(j!=0) { i=j%2; j=j/2; if(i==0) Binary[k++]='0'; else Binary[k++]='1'; } str.Format("%s",Binary); return str; } void CNMPDrivesClass::NMPReturnNoOfDrives(CUIntArray &NoOfDrives) { CString str; DWORD dwordVar=::GetLogicalDrives(); str=this->NMPChangeToBinary(dwordVar); for( int drive = 0; drive < 26; drive++ ) { if(str.GetAt(drive)=='1') { NoOfDrives.Add('A'+drive); } } } [/code] ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

      M 1 Reply Last reply
      0
      • T ThatsAlok

        Hello Madame Nazar I think this little piece of code can help you [code] CString CNMPDrivesClass::NMPChangeToBinary(DWORD dwVar) { long j=(long)dwVar; int i,k=0; char Binary[20]; CString str; str.Format("%d",j); while(j!=0) { i=j%2; j=j/2; if(i==0) Binary[k++]='0'; else Binary[k++]='1'; } str.Format("%s",Binary); return str; } void CNMPDrivesClass::NMPReturnNoOfDrives(CUIntArray &NoOfDrives) { CString str; DWORD dwordVar=::GetLogicalDrives(); str=this->NMPChangeToBinary(dwordVar); for( int drive = 0; drive < 26; drive++ ) { if(str.GetAt(drive)=='1') { NoOfDrives.Add('A'+drive); } } } [/code] ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

        M Offline
        M Offline
        missnazar
        wrote on last edited by
        #3

        Hi Mr. Alok, Thanx for replying. Now can u please tell me how am I going to connect this code to my combobox.So that logical drives are visible.I have compiled your code. Its error free. But am not getting when and where to call NMPReturnNoOfDrives function in my application?? Thanking u in advance, Drushti

        T 1 Reply Last reply
        0
        • M missnazar

          Hi Mr. Alok, Thanx for replying. Now can u please tell me how am I going to connect this code to my combobox.So that logical drives are visible.I have compiled your code. Its error free. But am not getting when and where to call NMPReturnNoOfDrives function in my application?? Thanking u in advance, Drushti

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          Hello Miss Nazar, it upto when to call these function as i don't know wheather you want to fill combo box on Initialization of Application or at middle. these code are from my article,i had already published that under name of 'sysutil' u can check that. anyway here it is small explaination->these fucntion return a mfc collection class,which contain all the drives letter in it one by one. the below given funtion check type of Drive. ////////////////this function send the type of drives //0 stand for floppy dirive //1 stand for hardisk //2 stand for cdrom //3 stand for ramdisk //4 stand for Network Drive //5 stand for unkown void CNMPDrivesClass::SendTypeOFDrives(CUIntArray &Stat) { CUIntArray Stat1;//this vaiable is created for getting drives list this->NMPReturnNoOfDrives(Stat1);//getting drives CString str; for(int i=0;i"I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups