Getting the Machine ID

  • Thread starter Thread starter Andy Levy
  • Start date Start date
A

Andy Levy

As far as i know - almost every PC has a machine ID. Is it possible to get
this machine number using a VBA command.

Thanks

AL
 
Here's the code to get the harddisk S/N:

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
www.pcdatasheet.com

Code To Get The Hard Disk Serial Number



Private Declare Function getHarddiskSerialnumber 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


Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim HDSNNum As Long
Dim VolName As String
Dim HarddiskSerialnumber As Long
Dim Maxlen As Long
Dim Sysflag As Long
Dim fsysName As String
HDSNNum = getHarddiskSerialnumber("c:\", VolName, 256, _
HarddiskSerialnumber, Maxlen, Sysflag, fsysName, 256)
MsgBox HDSNNum
Exit Sub
Err_Form_Load:
End Sub
 
That's not the hard disk serial number. It's the *volume* serial number, a
completely different (and user-changeable) thing :-)

It was possible to get the actual hard disk seial number in win95 (& 98?)
using a very weird CreateFile API call & some related code. But this won't
work in win2000+ :-(

TC
 
Back
Top