Reading desktop/Notebook serial number or system ID

  • Thread starter Thread starter OMER
  • Start date Start date
O

OMER

Hola,
I need to know how to read serial number, system ID or Windows ID from an
Excel macro.
I want to use this to limit a workbook to run only on the desktop/notebook
that is licensed to.

Any help on achieving this or an alternative method is highly appreciated.
Regards,
 
Forgot to mention that is for Excel 2007 and I want ot do this from the
opening workbook macro.
Thanks
 
You could try the GetVolumeInformation API:

Private 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 getDriveVolumeSerial(Optional strDriveLetter As String) As String

'will get the drive serial number
'default is the drive that the application is on
'otherwise can do for example: getDriveSerialNumber("D")
'-------------------------------------------------------

Dim strDrivePath As String
Dim Serial As Long
Dim VName As String
Dim FSName As String

If Len(strDriveLetter) = 0 Then
strDrivePath = Left$(Application.Path, 1) & ":\"
Else
strDrivePath = strDriveLetter & ":\"
End If

'Create buffers
VName = String$(255, Chr$(0))
FSName = String$(255, Chr$(0))

'Get the volume information
GetVolumeInformation strDrivePath, VName, 255, Serial, 0, 0, FSName, 255

getDriveVolumeSerial = Trim(Str$(Abs(Serial)))

End Function


Run it from the ThisWorkbook module in the Private Sub Workbook_Open()



RBS
 
I assume that since these are functions I can used them as regular
user-defined functions and assigned them to a specific cell. Is that
correct?

Yes, that should work, but not sure why you would want that.

RBS
 
The whole picture is that I want to tie the ID to the workbook, so that it
only runs in the registered machine. Any other ideas?

OMER
 
Back
Top