Click here to Skip to main content
15,921,530 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know how many drives in a system exists by executing programs.

can anybody reply me at rahul.prakash257@gmail.com
Posted

see below code. It lists all drives including mapped drives
C++
DWORD dwLogicalDrives = GetLogicalDrives() << 1;
int nIdx = 1;
char chDrive = 'A';
CString csDrive;

while( dwLogicalDrives )
{
    if(dwLogicalDrives & static_cast<int>( pow( 2, nIdx )))
    {
        csDrive = chDrive; 
        AfxMessageBox( csDrive );
    }
    ++nIdx; 
    ++chDrive;
}</int>
 
Share this answer
 
Use can also use WMI for it. For more information on WMI, google it :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900