Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Visual Basic Programming Code Examples

Visual Basic > Code Snippets Code Examples

Detect if media in drive

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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