To support drives on a computer, the Win32 library provides the GetLogicalDrives() function of Microsoft Window. Its syntax is:
DWORD WINAPI GetLogicalDrives(void);
When this method is called, it produces a list of all drives on the current computer. Each drive is represented by a bit in the integral returned value. Here is an example of calling this function:
void CLogicalDrives1Dlg::OnBnClickedLogicaldrivesBtn() { wchar_t drive[512] = L"A:"; unsigned int drives = GetLogicalDrives(); CString strListOfDrives = L"The list of drives is "; if( drives == 0 ) AfxMessageBox(L"There is no drive to show"); else { while(drives) { if( drives & 1 ) { strListOfDrives += drive; strListOfDrives += L", "; } drive[0]++; drives >>= 1; } m_ListOfDrives = strListOfDrives; UpdateData(FALSE); } }
