3.3. Getting Drive Types

You can use the GetDriveType function to determine the type of any drive connected to your system. Listing 3.2 shows you how to use this function.

Code Listing 3.2. Checking the drive type with the GetDriveType function
 // drvtype.cpp #include <windows.h> #include <iostream.h> void main() { UINT driveType; // Get the drive type for drive C driveType = GetDriveType("c:\\"); switch (driveType) { case 0: cout << "error\n"; break; case 1: cout << "Drive does not exist\n"; break; case DRIVE_REMOVABLE: cout << "Media removable\n"; break; case DRIVE_FIXED: cout << "Fixed disk\n"; break; case DRIVE_REMOTE: cout << "Network drive\n"; break; case DRIVE_CDROM: cout << "CD-ROM drive\n"; break; case DRIVE_RAMDISK: cout << "RAM disk\n"; ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.