PEGAR NRO DE HD
galera..Me desculpem, eu sei que tem aqui no site, mas infelizmente não achei. COmo pego o nro do HD pelo VB ?
Obrigado !!!
Obrigado !!!
amigo os links abaixo, caso não consiga me avise q a noite eu te mando um exemplo q estou usando ....
[txt-color=#ff0000]EXEMPLO1[/txt-color]
[txt-color=#0000ff]EXEMPLO2[/txt-color]
[txt-color=#ff0000]EXEMPLO1[/txt-color]
[txt-color=#0000ff]EXEMPLO2[/txt-color]
BOM , ACHO Q ESSA API VAI TE SERVIR
Public 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
============================== FUNCTION Q FAZ O TRATAMENTO
Public Function fc_Get_Number_serie_HD(ByVal par_cunid As String) As String
Dim var_SerialNumber As Long
Dim par_cNameVolume As String * 255
Dim par_cNameSystem As String * 255
On Error GoTo erro_
Call GetVolumeInformation(par_cunid, par_cNameVolume, Len(par_cNameVolume), var_SerialNumber, 0, 0, par_cNameSystem, Len(par_cNameSystem))
fc_Get_Number_serie_HD = Hex$(var_SerialNumber)
fc_Get_Number_serie_HD = Left$(fc_Get_Number_serie_HD, 4) & "#" & Right$(fc_Get_Number_serie_HD, 4)
Exit Function
erro_:
MsgBox Err.Description & " " & Err.Number, vbCritical, "Get_Number_serie_HD"
End Function
====================================================================
ESPERO TER AJUDADO
Public 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
============================== FUNCTION Q FAZ O TRATAMENTO
Public Function fc_Get_Number_serie_HD(ByVal par_cunid As String) As String
Dim var_SerialNumber As Long
Dim par_cNameVolume As String * 255
Dim par_cNameSystem As String * 255
On Error GoTo erro_
Call GetVolumeInformation(par_cunid, par_cNameVolume, Len(par_cNameVolume), var_SerialNumber, 0, 0, par_cNameSystem, Len(par_cNameSystem))
fc_Get_Number_serie_HD = Hex$(var_SerialNumber)
fc_Get_Number_serie_HD = Left$(fc_Get_Number_serie_HD, 4) & "#" & Right$(fc_Get_Number_serie_HD, 4)
Exit Function
erro_:
MsgBox Err.Description & " " & Err.Number, vbCritical, "Get_Number_serie_HD"
End Function
====================================================================
ESPERO TER AJUDADO
Só me traz "0"....em todos os exemplos....teriam alguma idéia ?
Tenho este exemplo tambem
Dim lSerial as Long
Dim fso As New FileSystemObject, drvDrive As Drive
'Pega as informações do drive c:
Set drvDrive = fso.GetDrive(left(fso.GetDriveName("c:"), 2))
'Pega o número de série do HD
lSerial = drvDrive.SerialNumber
E não esqueça de adicionar aos references do seu projeto a seguinte biblioteca "Microsoft Scripting Runtime", senão não funciona
Dim lSerial as Long
Dim fso As New FileSystemObject, drvDrive As Drive
'Pega as informações do drive c:
Set drvDrive = fso.GetDrive(left(fso.GetDriveName("c:"), 2))
'Pega o número de série do HD
lSerial = drvDrive.SerialNumber
E não esqueça de adicionar aos references do seu projeto a seguinte biblioteca "Microsoft Scripting Runtime", senão não funciona
Tópico encerrado , respostas não são mais permitidas