tags:

views:

28

answers:

1

Hi,

I have a MFC Combobox i want to add A-Z drives to my combox at runtime Currently i am adding like this

m_cmbdrive.AddString("A:"); 
    m_cmbdrive.AddString("B:"); 
    m_cmbdrive.AddString("C:")

upto

m_cmbdrive.AddString("Z:"); 

But it seems not to be gud approach . Any modularlize code if any body can help on this ?

A: 
char drive[3];
drive[1]=':';
drive[2]='\0';
for (drive[0]='A';drive[0]<='Z';drive[0]++)
{
     m_cmbdrive.AddString(drive);
}

Of course, you should check if drive is available at all before adding it into the combo, et cetera.

Daniel Mošmondor
I would use GetLogicalDrives or GetLogicalDriveStrings.
Luke