View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob van Gelder[_4_] Rob van Gelder[_4_] is offline
external usenet poster
 
Posts: 1,236
Default Unique ID/Name for a computer?

Lots of application protection schemes use a combination of hardware
identifiers (MAC address, Vol Serial etc...)

Here's some code to pull C: Volume Serial Number

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

Sub test()
Const cMaxPath = 256, cDrive = "C:\"

Dim strTemp As String, lngRet As Long
Dim lngVolSerial As Long, strVolName As String * cMaxPath
Dim lngMaxCompLen As Long, lngFileSysFlags As Long
Dim strFileSysName As String * cMaxPath

lngRet = GetVolumeInformation(cDrive, strVolName, cMaxPath, lngTemp, _
lngMaxCompLen, lngFileSysFlags, strFileSysName, cMaxPath)
strTemp = Format(Hex(lngTemp), "00000000")
strTemp = Left(strTemp, 4) & "-" & Right(strTemp, 4)

MsgBox strTemp
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Warren" wrote in message
...
All,
1) Is there a way to identify a PC that excel is running on? I.e., IP

address maybe?.
2) If there is, can I use VBA to somehow grab the id/name?
3) If so, what would the code look like?
Thanks in Advance, -Warren