5 Replies - 823 Views - Last Post: 11 February 2013 - 09:49 PM Rate Topic: -----

#1 mr.nacho  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 103
  • Joined: 28-December 12

[QUESTION] Drive Letter of Flash Drive

Posted 08 February 2013 - 05:47 AM

Can I use sysinfo object to determine the drive letter of the flash drive? Thanks for the help.
Is This A Good Question/Topic? 0
  • +

Replies To: [QUESTION] Drive Letter of Flash Drive

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: [QUESTION] Drive Letter of Flash Drive

Posted 10 February 2013 - 11:34 AM

You can use WMI to get this information.
Was This Post Helpful? 1
  • +
  • -

#3 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3594
  • View blog
  • Posts: 12,365
  • Joined: 12-December 12

Re: [QUESTION] Drive Letter of Flash Drive

Posted 10 February 2013 - 11:52 AM

You can use the FileSystemObject to check the DriveType (IF YOU ARE USING VB6..?)

Function ShowDriveType(drvpath)
   Dim fso, d, t
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set d = fso.GetDrive(drvpath)
   Select Case d.DriveType
      Case 0: t = "Unknown"
      Case 1: t = "Removable"
      Case 2: t = "Fixed"
      Case 3: t = "Network"
      Case 4: t = "CD-ROM"
      Case 5: t = "RAM Disk"
   End Select
   ShowDriveType = "Drive " & d.DriveLetter & ": - " & t
End Function

MSDN

A flash drive would return 1 (Removable). You can loop through all drives:

Sub CheckDriveTypes()
    Dim fso As New FileSystemObject
    Dim ds As Object
    'loop through all drives
    For Each ds In fso.Drives
        Debug.Print ds.DriveLetter
        Debug.Print ds.DriveType
    Next ds
End Sub

Does WMI return more information other than "Removable"?

This post has been edited by andrewsw: 10 February 2013 - 11:53 AM

Was This Post Helpful? 1
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: [QUESTION] Drive Letter of Flash Drive

Posted 11 February 2013 - 07:03 PM

Quote

Does WMI return more information other than "Removable"?


:) see for yourself: http://msdn.microsof...2(v=vs.85).aspx
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3594
  • View blog
  • Posts: 12,365
  • Joined: 12-December 12

Re: [QUESTION] Drive Letter of Flash Drive

Posted 11 February 2013 - 07:14 PM

View PostBobRodes, on 11 February 2013 - 07:03 PM, said:

Quote

Does WMI return more information other than "Removable"?


:)/> see for yourself: http://msdn.microsof...2(v=vs.85).aspx

I assumed it would do :) although I'm not sure which of the available properties would confirm that it is a flash-drive. Probably MediaType:

Quote

External hard disk media
Removable media other than floppy
Fixed hard disk media
Format is unknown


Although, I haven't seen a floppy-drive for a while :whistling:
Was This Post Helpful? 0
  • +
  • -

#6 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: [QUESTION] Drive Letter of Flash Drive

Posted 11 February 2013 - 09:49 PM

Look at Capabilities(7) too.

Here's some more relevant info, although it's in Delphi.

This post has been edited by BobRodes: 11 February 2013 - 10:21 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1