[API]
STORAGE_HOTPLUG_INFO
CreateFileA
DeviceIoControl
CloseHandle

[INCLUDE]
Application
OSVersionDependent

[DIRECTIVE]
SetIsMinWindows2000W

[CODE]
Public Function IsRemoveableDrive(ByVal DriveLetterID As Long) As Boolean
  Dim xType1 As STORAGE_HOTPLUG_INFO
  Dim xLong1 As Long
  
  If IsMinWindows2000W Then
    DriveLetterID = CreateFileA("\\.\" + Chr(65& + DriveLetterID) & ":", 0&, 3&, 0&, 3&, 0, 0&)
    If Not DriveLetterID = -1& Then
      If Not DeviceIoControl(DriveLetterID, &H2D0C14, ByVal 0&, 0&, xType1, 9&, xLong1, 0&) = 0& Then
        IsRemoveableDrive = Not (xType1.MediaRemovable = 0& And xType1.DeviceHotplug = 0&)
        End If
      Call CloseHandle(DriveLetterID)
      End If
    End If
  End Function
