Re: Detecting a removable drive in VB6
- From: "Dave O." <nobody@xxxxxxxxxxx>
- Date: Tue, 12 Sep 2006 10:20:11 +0100
Jim
The easy way to differentiate a floppy is not many USB drive have a capacity
of just 1.44 Meg. So it would be reasonable to assume any drive with a
capacity of under (say) 4Meg is a floppy of some kind. There may be some
older media cards which have very low capacities, but I can't see many
people using them seriously.
Regards
Dave O.
"Jim Carlock" <anonymous@localhost> wrote in message
news:eIseypD1GHA.5048@xxxxxxxxxxxxxxxxxxxxxxx
Garry <garrygrolman@xxxxxxxxx> schrieb:
I need to know if a path is on a removable memory stick or drive.
What API will give me this answer going back to possibly win ME.
However, limited to Win 2K or XP will still give me a handle
"Thorsten Albers" <albersRE@xxxxxxxxxxxxxxxxxxx> replied:
GetDriveType() works on all versions of Windows.
Unfortunately I can't tell you what it returns for a memory stick
- but it should return DRIVE_REMOVABLE, or, at least, not
DRIVE_FIXED.
GetDriveType() returns 2 (REMOVABLE) for a SanDisk USB
stick. Unfortunately, a floppy disk returns the same information.
Hard to tell what the OP is asking, because a removable memory
stick is a drive in the eyes of the OS.
Private Declare Function GetVolumeInformation Lib "Kernel32" _
Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) As Long
'pass drive letter in as "Z:\" with the colon and backslash
Function GetFileSystem(sDrvLetter As String) As String
'...
Dim sVName As String 'volume name
Dim sFSName As String 'file system name/type
Dim sSerial As String 'serial number(?) IF present
Dim iResult As Long
iResult = GetVolumeInformation(sDrvLetter, sVName, _
255, sSerial, 0, 0, sFSName, 255)
GetFileSystem = Left$(sFSName, InStr(1, sFSName, Chr$(0)) - 1)
End Function
sSerial returns the serial number (if one is burned into the
ROM/Flash), as well as the File System (FAT/NTFS).
Perhaps there's another API that digs a little deeper and can
differentiate a Flash drive from a floppy disk drive. He'll need a
table or database of driver strings to go further and possibly
check some registry values against.
The DeviceIoControl() API might be helpful as well.
http://msdn.microsoft.com/library/en-us/devio/base/deviceiocontrol.asp
Hope this helps.
--
Jim Carlock
Post replies to the group.
.
- Follow-Ups:
- Re: Detecting a removable drive in VB6
- From: Karl E. Peterson
- Re: Detecting a removable drive in VB6
- References:
- Detecting a removable drive in VB6
- From: Garry
- Re: Detecting a removable drive in VB6
- From: Thorsten Albers
- Re: Detecting a removable drive in VB6
- From: Jim Carlock
- Detecting a removable drive in VB6
- Prev by Date: Using ShellExec to Invoke an Outgoing E-Mail Message
- Next by Date: Re: Detecting a removable drive in VB6
- Previous by thread: Re: Detecting a removable drive in VB6
- Next by thread: Re: Detecting a removable drive in VB6
- Index(es):
Relevant Pages
|