Reading the Hard Drives Serial Number
Try this
' ****************** Code Start ********************
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 VolSerialNo(lpRootPathName As String) As String
Dim lngRet As Long
Dim lpVolumeNameBuffer As String
Dim nVolumeNameSize As Long
Dim lpVolumeSerialNumber As Long
Dim lpMaximumComponentLength As Long
Dim lpFileSystemFlags As Long
Dim lpFileSystemNameBuffer As String
Dim nFileSystemNameSize As Long
lngRet = GetVolumeInformation(lpRootPathName, _
lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber, _
lpMaximumComponentLength, lpFileSystemFlags, _
lpFileSystemNameBuffer, nFileSystemNameSize)
If lngRet <> 0 Then
lngRet = lpVolumeSerialNumber
End If
'at this point you can either return lngRet (the Decimal representation,
'change the function Declaration to As Long)
'or keep this function as is to return the xxxx-xxxx representation you
'get with Vol or Dir
End Function
' ****************** Code Start ********************
Call it with something like
VolSerialNo("c:\")
Quote:
>I am writing a shareware program in Access 97. As usuall I need to lock
>the program until it is registered. I would like to read and store the
>serial number of the boot drive on the initial load. And then check it
>everytime to see if it has been copied or legit.
>Does anybody know how to do this?
>Or is there a better way of checking?
>-------------------
>Arthur Christy
>Power Micro Corporation
>http://www.powermicrocorp.com