Re: Detecting a removable drive in VB6

Tech-Archive recommends: Fix windows errors by optimizing your registry



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.




.



Relevant Pages

  • Re: PCW8256 Unerase
    ... copy the whole lot back to floppy. ... unerase utility like U3.COM may make things quicker. ... the word at HL points to a 3-byte string ... This is what a nice clean life leads to. ...
    (comp.sys.amstrad.8bit)
  • Re: Problems module autoload in 2.6.x
    ... option for modprobe from the kernel. ... The string is coded in the module.c in 2.4.x. ... The lsmod or cat /proc/modules don't gives ... the floppy module ...
    (Linux-Kernel)
  • Re: [opensuse] Assembly Language program
    ... i am about to make a bootable floppy for test ... call _boot #call the boot section ... %si /*move the address of the character string ... call _disp #call subroutine disp ...
    (SuSE)
  • Re: Using bottom 4 strings of 5 string set on a 4 string bass?
    ... tension because BEAD has less string tension than standard tuning. ... string will be more floppy at the same tension. ... I haven't measured the tension of BEAD versus EADG, so I can't say which has ...
    (alt.guitar.bass)
  • Re: StringBuilder termination char
    ... You have to make sure that the StringBuilder object is big enough to hold ... You are setting it's capacity to len + 1, ... Dim _ssAs String = _s.Split ...
    (microsoft.public.dotnet.languages.vb)