Differenze tra le versioni di "Conoscere i dispositivi pen-drive usb montati sul sistema"
Da Gambas-it.org - Wikipedia.
(Creata pagina con "Per ottenere un elenco delle pen-drive USB montate sul proprio sistema, è possibile adottare il seguente codice: Private Const DEV_DISK As String = "/dev/disk/by-id" ''...") |
|||
Riga 3: | Riga 3: | ||
− | + | Public Sub Main() | |
Dim usb, s As String | Dim usb, s As String | ||
− | + | For Each usb In Dir(DEV_DISK, "*", gb.Device) | |
− | + | If Left(usb, 3) = "usb" Then | |
− | + | If Left(usb, RInStr(usb, "_") - 1) <> s Then Print Left(usb, RInStr(usb, "_") - 1) | |
− | + | s = Left(usb, RInStr(usb, "_") - 1) | |
− | + | Endif | |
− | + | Next | |
− | + | End |
Versione attuale delle 16:22, 8 ott 2023
Per ottenere un elenco delle pen-drive USB montate sul proprio sistema, è possibile adottare il seguente codice:
Private Const DEV_DISK As String = "/dev/disk/by-id" Public Sub Main() Dim usb, s As String For Each usb In Dir(DEV_DISK, "*", gb.Device) If Left(usb, 3) = "usb" Then If Left(usb, RInStr(usb, "_") - 1) <> s Then Print Left(usb, RInStr(usb, "_") - 1) s = Left(usb, RInStr(usb, "_") - 1) Endif Next End