Saberexcel - o site de quem precisa Aprender Macros Microsoft Excel VBA
Retorna o Número serial do HD do computador
Saberexcel - Dicas do aplicativo microsoft Excel VBA
Esta macro com as funções e declarações retorna uma mensagem com o número do HD do
seu computador mostro aqui duas funções.
Private Declare Function GetVolumeInformation& Lib "Kernel32" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, _
ByVal pVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemName As Long)
Private Const MAX_FILENAME_LEN = 256
Public Function GetSerialNumber(sDrive As String) As Long
Dim ser As Long
Dim s As String * MAX_FILENAME_LEN
Dim s2 As String * MAX_FILENAME_LEN
Dim j As Long
Dim i As Long
Call GetVolumeInformation _
(sDrive + ":\", s, MAX_FILENAME_LEN, ser, i, j, s2, MAX_FILENAME_LEN)
GetSerialNumber = ser
End Function
Sub Teste_Numero_HD()
MsgBox ("Número do HD ") & GetSerialNumber("C"), vbInformation, "Saberexcel - o site das macros"
MsgBox ("Número do HD ") & DriveSerialNumber("c"), vbInformation, "Saberexcel - o site das macros"
End Sub
Function DriveSerialNumber(Lecteur)
Dim sab, d
Set sab = CreateObject("Scripting.FileSystemObject")
Set d = sab.GetDrive(sab.GetDriveName _
(sab.GetAbsolutePathName(Lecteur & ":\")))
DriveSerialNumber = d.SerialNumber
End Function
Aprenda tudos sobre o Aplicativo microsoft Excel VBA - com SaberExcel
Baixe a planilha exemplo das funções acima
Excel planilha vba sistema retorna o numero do hd do computador (32.72 kB)
Comentários
Assine o RSS dos comentários