borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (duplicates Item from a ListView)Next Topic (access files properties) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Displaying Drive letters
Poster Message
goldenmusketeer
Level: Whizz Kid


Registered: 23-12-2004
Posts: 16

icon Displaying Drive letters

Hiiiiiiiiiiiiii Guys,
          Got a problem for you ppl.  
I have a drivecombo control..In that control I don't want to show the removable drive(F/D, CD-ROM ,CR-RW Drive) but I Want to show a "PEN DRIVE"..Can you guys give me a suggesstion on how to achieve that. If it can done with any other control, that also will do.
  

[Edited by goldenmusketeer on 17-01-2006 at 11:15 PM GMT]

____________________________
.....Joy

17-01-2006 at 06:13 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Displaying Drive letters

Hi,
You could use the Scripting FileSystemObject to enumerate the Drives and get their types :-

Sub ShowDriveList
    Dim fs, d, dc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set dc = fs.Drives
    For Each d in dc
        s = s & d.DriveLetter & " - " & d.DriveType & vbCrLf
        Next
    MsgBox s
End Sub


Drive Types are :-
0 - Unknown - Drive type can't be determined.
1 - Removable - Drive has removable media. This includes all floppy drives and many other varieties of storage devices.
2 - Fixed - Drive has fixed (nonremovable) media. This includes all hard drives, including hard drives that are removable.
3 - Remote - Network drives. This includes drives shared anywhere on a network.
4 - CDROM - Drive is a CD-ROM. No distinction is made between read-only and read/write CD-ROM drives.
5 - RAMDisk - Drive is a block of Random Access Memory (RAM) on the local computer that behaves like a disk drive.

Hope that helps.


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

18-01-2006 at 12:34 PM
View Profile Send Email to User Show All Posts | Quote Reply
goldenmusketeer
Level: Whizz Kid


Registered: 23-12-2004
Posts: 16
icon Re: Displaying Drive letters

Thanks Geoff,
         but the problem is something else. What you said I already did. But the problem is when I connect a "PEN DRIVE" it 's drivetype =1.So it's very hard to distinguish Floppy & Pen Drive. Again on the other hand if the drive letter is changed, we cannot run a validation on "A:\" as floppy...I can't find a way out to solve this. I mean if I conditionally (based on drivetype) remove the list of removable discs, "PEN DRIVE" is also removed from list.....



____________________________
.....Joy

18-01-2006 at 04:11 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Displaying Drive letters

I appreciate that you cannot remove all drives of type "1" from your list, but working on the basis that Drive letters "A" and "B" are reserved for floppy drives you could reasonably assume that any drive type 1 that is not A or B must be a pen drive. I know that we should not really make assumtions, but I believe its a reasonable one under the circumstances.
Of course, this all goes out the window if there is a likelyhood of a tape drive, as this would also show as "1".  


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

18-01-2006 at 04:37 PM
View Profile Send Email to User Show All Posts | Quote Reply
mjahkoh
Level: Protégé

Registered: 21-03-2006
Posts: 8
icon Re: Displaying Drive letters - Not Quite

Hi Guys.
VB Lord - The solution given only displays drive letters and types. To ask again for instance if i had 1 hdd partitioned in two, the code given displays 2 harddrives. What i wanted was the number of PHYSICAL HARDDRIVES connected to system as opposed to LOGICAL DRIVES. in my case it should just list 1 hdd
Thanks

23-03-2006 at 11:09 AM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 530
icon Re: Displaying Drive letters

take a look at this code:

http://vbnet.mvps.org/index.html?code/disk/deviodriveinfo.htm

maybe it can help goldenmusketeer in determinating if a drive is a removable pen drive or not, and will also help mjahkoh in enumerating physical hard disks showing size, type and geometry

____________________________
AndreaVB

24-03-2006 at 10:31 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB General : Displaying Drive letters
Previous Topic (duplicates Item from a ListView)Next Topic (access files properties) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder