MFC enlisting local drives
-
Hi, I want to enlist local drives with their icons in the combobox . How can I do that? Drushti
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
-
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
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
-
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
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