Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/10/2004, 22:54
pablosavino
 
Fecha de Ingreso: septiembre-2004
Mensajes: 72
Antigüedad: 20 años, 5 meses
Puntos: 0
Cita:
Iniciado por VaFG
Hola a todos,

Alguien conoce alguna función de la API de Windows que me permita obtener el número de serie del disco duro.

Gracias de antemano.
Hola

En Declaraciones pon este llamado a la API

Private Declare Function GetVolumeSerialNumber Lib "kernel32.dll" 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


En el formulario esto

Public Function VolumeSerialNumber(ByVal RootPath As String) As String
Dim VolLabel As String
Dim VolSize As Long
Dim Serial As Long
Dim MaxLen As Long
Dim Flags As Long
Dim Name As String
Dim NameSize As Long
Dim s As String

If GetVolumeSerialNumber(RootPath, VolLabel, VolSize, Serial, MaxLen, Flags, Name, NameSize) Then
'Crea un strin de 8 caracteres
s = Format(Hex(Serial), "00000000")

VolumeSerialNumber = Left(s, 4) + "-" + Right(s, 4)
Else
'Si falla, devolvemos ceros
VolumeSerialNumber = "0000-0000"
End If
End Function

Uso de la funcion:
Private Sub Command1_Click()
MsgBox VolumeSerialNumber(Text1.Text & ":\")
End Sub

Saludos
__________________
Pablo F. Savino
---------------

Para aficionados a la Simulacion Aerea Virtual ,
visiten:
http://www.cargovirtual.com