View Single Post
  #10   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?

Dim strVolName As String * cMaxPath
in classic VB defines a fixed length string.

This has probably gone missing in .Net

The alternative is to dim the variable as string then make sure it's
long enough before using it.

Dim strVolName As String
Dim strFileSysName As String
strVolName = String$(255, Chr$(0))
strFileSysName = String$(255, Chr$(0))

also works in classic VB.

If the String$ function has also gone missing in .Net you may need to
try something else similar

Gehres wrote:

Hi,
this thread is just what I was looking for -- much thanks to all !
Having said that, I am going to show my ignorance.
I program in Visual Studio .NET VB for a while now & have not come accross
a part of your example :

strVolName As String * cMaxPath

VB gives me an error on the "* cMaxPath" expects end ot statment.

Not sure what this syntax means - Thanks Again


----- Frank Kabel wrote: -----

Hi
you may use the HD drive ID for this. The following code gets this
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

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
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)

get_drive_serial = strTemp
End Sub



--
Regards
Frank Kabel
Frankfurt, Germany


Hello, ..Hope you all enjoyed the jollies
Does anybody know a routine to get an unique ID from each computer. I

would like to use it for preventative copying.
Thanks for looking

CAA
---

Message posted from http://www.ExcelForum.com/