- Код: Выделить всё
#Compile Exe
#Dim All
#Include "win32api.inc"
Function GetDiskUSB() As String
Local Ret As Long, Cnt As Long, lzStr As Asciiz * 4
For Cnt = 3 To 26
lzStr = Chr$(Cnt + &h40) + ":\"
Ret = GetDriveType (lzStr)
If Ret = %DRIVE_REMOVABLE Then
If DiskFree(Left$(lzStr,1)) Then
Function = Left$(lzStr,2)
Exit Function
End If
End If
Next
Function = ""
End Function
Function PBMain () As Long
Do
Sleep 3000
Loop Until GetDiskUSB <> ""
MsgBox "Подключен USB накопитель " & GetDiskUSB
Do
Sleep 3000
Loop Until GetDiskUSB = ""
MsgBox "Отключен USB накопитель " & GetDiskUSB
End Function