LISTA UNIDADES - LETRAS E NOME
Boa tarde, alguem sabe como colocar em uma combo as unidades de disco do sitema, tipo:
Disco Local (C:)
Unidade de CDRUM (D:)
disco removivel (E:)
Disco Local (C:)
Unidade de CDRUM (D:)
disco removivel (E:)
utilize o DriveListBox na barra de ferramentas...
Num módulo:
Private 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
Public Function BuscaNomeDrive(Drive As String) As String
[ô]create working variables
[ô]to keep it simple, use dummy variables for info
[ô]we[ô]re not interested in right now
Dim r As Long
Dim pos As Integer
Dim hword As Long
Dim HiHexStr As String
Dim lword As Long
Dim LoHexStr As String
Dim VolumeSN As Long
Dim MaxFNLen As Long
Dim UnusedStr As String
Dim UnusedVal1 As Long
Dim UnusedVal2 As Long
[ô]pad the strings
DrvVolumeName = Space$(14)
UnusedStr = Space$(32)
[ô]do what it says
r = GetVolumeInformation(Drive, _
DrvVolumeName, _
Len(DrvVolumeName), _
VolumeSN&, _
UnusedVal1, UnusedVal2, _
UnusedStr, Len(UnusedStr))
If r = 0 Then Exit Function
pos = InStr(DrvVolumeName, Chr$(0))
If pos Then DrvVolumeName = Left$(DrvVolumeName, pos - 1)
If Len(Trim$(DrvVolumeName)) = 0 Then DrvVolumeName = [Ô](Sem nome)[Ô]
BuscaNomeDrive = DrvVolumeName
End Function
Num form, onde quiser buscar:
MsgBox BuscaNomeDrive([Ô]C:\[Ô]) [ô]Ou [Ô]D:\[Ô], para ter uma lista de drives disponÃveis use o drivelistbox, que é nativo do VB
Private 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
Public Function BuscaNomeDrive(Drive As String) As String
[ô]create working variables
[ô]to keep it simple, use dummy variables for info
[ô]we[ô]re not interested in right now
Dim r As Long
Dim pos As Integer
Dim hword As Long
Dim HiHexStr As String
Dim lword As Long
Dim LoHexStr As String
Dim VolumeSN As Long
Dim MaxFNLen As Long
Dim UnusedStr As String
Dim UnusedVal1 As Long
Dim UnusedVal2 As Long
[ô]pad the strings
DrvVolumeName = Space$(14)
UnusedStr = Space$(32)
[ô]do what it says
r = GetVolumeInformation(Drive, _
DrvVolumeName, _
Len(DrvVolumeName), _
VolumeSN&, _
UnusedVal1, UnusedVal2, _
UnusedStr, Len(UnusedStr))
If r = 0 Then Exit Function
pos = InStr(DrvVolumeName, Chr$(0))
If pos Then DrvVolumeName = Left$(DrvVolumeName, pos - 1)
If Len(Trim$(DrvVolumeName)) = 0 Then DrvVolumeName = [Ô](Sem nome)[Ô]
BuscaNomeDrive = DrvVolumeName
End Function
Num form, onde quiser buscar:
MsgBox BuscaNomeDrive([Ô]C:\[Ô]) [ô]Ou [Ô]D:\[Ô], para ter uma lista de drives disponÃveis use o drivelistbox, que é nativo do VB
KERPLUNK não funcionou, se eu for em meu computador aparece assim PendriveJG (F:)
usando a funcao aparece: (Sem Nome)
usando a funcao aparece: (Sem Nome)
Mas alguem sabe como fazer?
Veja este código.
Use a dica do DEKINHO...
Um DriveListBox, é o que eu uso em meus programas que fazem backup...
Funciona 100%
Um DriveListBox, é o que eu uso em meus programas que fazem backup...
Funciona 100%
Tópico encerrado , respostas não são mais permitidas