finding drives

This is a discussion on finding drives within the Windows Programming forums, part of the Platform Specific Boards category; how can i find out all of the drives that a user has, in C++, without using any API's (i ...

  1. #1
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903

    finding drives

    how can i find out all of the drives that a user has, in C++, without using any API's (i mean without having to use a win32 text box or something....)

    searched msdn, but didn't find much

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    UK
    Posts
    169
    You could try something like this.
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    int main()
    {
       char drive[] = "c:";
       char i;
       UINT rc;
    
       for(i='c'; i <= 'z'; i++)
       {
    	   drive[0] = i;
    	   rc = GetDriveType( drive );
    
    	   switch(rc)
    	   {
    	   case DRIVE_UNKNOWN:
    		   break;
      	   case DRIVE_FIXED:
    		   printf("%s   - FIXED\n", drive);
    		   break;
      	   case DRIVE_REMOTE:
    		   break;   
      	   case DRIVE_CDROM:
    		   printf("%s   - CDROM\n", drive);
    		   break;
      	   case DRIVE_RAMDISK:
    		   break;   
      	   case DRIVE_REMOVABLE:
    		   break;
    	   }
       }
       return 0;
    }

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    GetLogicalDrives()

    You can get additional info on the drive with GetVolumeInformation() along with GetDriveType().

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Determine drives attached
    By niqo in forum Windows Programming
    Replies: 2
    Last Post: 10-05-2007, 09:49 AM
  2. USB Drives???
    By khpuce in forum Tech Board
    Replies: 14
    Last Post: 12-12-2003, 08:01 AM
  3. MFC :: Finding Child Window of a CWnd* Object?
    By SyntaxBubble in forum Windows Programming
    Replies: 2
    Last Post: 09-06-2003, 09:06 AM
  4. installing hard drives and IDE cables...
    By dbaryl in forum Tech Board
    Replies: 14
    Last Post: 09-02-2002, 10:11 AM
  5. Probs with CD drives
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 03-11-2002, 10:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21