Visual Basic > Code Snippets
Detect if media in drive
Detect if media in drive 'Add 1 CommandButton and 1 DriveListBox to your form. 'Choose in the DriveListBox the drive you want to detect, and press the button. 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 Private Sub Command1_Click() erg& = GetVolumeInformation(Drive1.Drive, VolName$, 127&, VolNumber&, MCM&, FSF&, FSys$, 127&) If erg& = 0 Then MsgBox "There is no media in the drive" Else MsgBox "There is media in the drive" End If End Sub
Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows