Getting the Machine ID

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
 
P

PC Datasheet

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
 
T

TC

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top