View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Steve Garman Steve Garman is offline
external usenet poster
 
Posts: 107
Default A unique ID for protection?

I'm not really very familiar with vb.net syntax and this thread is
rapidly drifting off-topic for this group.

However, you seem to have changed the logic of the function so that it
returns lngRet instead of lngtemp, which is where the volume serial
number for drive c:\ is returned.

lngRet is the return value of the API function and the only thing I know
about it for sure is that zero indicates failure.

Gehres wrote:

Hi again - more questions

to get this code to return a value in VB.NET I altered it to the code shown below. It returns a 16 digit integer/string but I am not sure what the value represents. The Function GetVolumeInformation is not specific as to the value it returns. Is that the physical hard drives serial #? if so How does one tell?

Declare Function GetVolumeInformation Lib "kernel32" Alias _
"GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal _
lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _
ByVal lpVolumeSerialNumber As Long, ByVal lpMaximumComponentLength As Long, _
ByVal lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) As Long

Function get_drive_serial()
Const cMaxPath = 256, cDrive = "C:\"
Dim lngtemp
Dim strTemp As String, lngRet As Long
Dim lngVolSerial As Long, strVolName As String = cMaxPath.ToString
Dim lngMaxCompLen As Long, lngFileSysFlags As Long
Dim strFileSysName As String = cMaxPath.ToString

lngRet = GetVolumeInformation(cDrive, strVolName, cMaxPath, _
lngtemp, lngMaxCompLen, lngFileSysFlags, strFileSysName, _
cMaxPath)

strTemp = lngRet.ToString

get_drive_serial = strTemp
End Function