Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default A unique ID for protection?

Hello, ..Hope you all enjoyed the jollies

Does anybody know a routine to get an unique ID from each computer.
would like to use it for preventative copying.

Thanks for looking
CA

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default A unique ID for protection?

Here is one way, get the C drive volume number

Function DiskVolumeId() As String
Dim FSO As Object

Set FSO = CreateObject("Scripting.FileSystemObject")
DiskVolumeId = Format(CDbl(FSO.Drives("C:").SerialNumber))
End Function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CAA " wrote in message
...
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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default A unique ID for protection?

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/


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default A unique ID for protection?

Hi Bob
this is not fair
I had the same idea but my code is much longer :-)

--
Regards
Frank Kabel
Frankfurt, Germany


Bob Phillips wrote:
Here is one way, get the C drive volume number

Function DiskVolumeId() As String
Dim FSO As Object

Set FSO = CreateObject("Scripting.FileSystemObject")
DiskVolumeId = Format(CDbl(FSO.Drives("C:").SerialNumber))
End Function


"CAA " wrote in message
...
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/


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default A unique ID for protection?

As I keep telling my kids, life ain't fair!

I once wrote a complex class for reading and writing to the registry, and
then WSH came out with a RegRead and RegWrite method. Half a dozen lines. So
don't talk to me about fair<G

Bob


"Frank Kabel" wrote in message
...
Hi Bob
this is not fair
I had the same idea but my code is much longer :-)

--
Regards
Frank Kabel
Frankfurt, Germany


Bob Phillips wrote:
Here is one way, get the C drive volume number

Function DiskVolumeId() As String
Dim FSO As Object

Set FSO = CreateObject("Scripting.FileSystemObject")
DiskVolumeId = Format(CDbl(FSO.Drives("C:").SerialNumber))
End Function


"CAA " wrote in message
...
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/






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default A unique ID for protection?

Excellent stuff Bob.

I'm amazed how simple you made that, i was expecting something mor
along the lines of Franks and the headache that follwed trying t
understand it, but now, ..wow. Very impressed.

Thankyou once again Bob for another on the ball answer.

Frank, what can i say, the guy on the motorbike will usually win th
marathon.

CA

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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default A unique ID for protection?

The thing about Frank's is that you don't need to understand it if you want
a solution. When we provide API solutions they are never obvious, APIs
aren't, but if they work, what the heck, use them.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CAA " wrote in message
...
Excellent stuff Bob.

I'm amazed how simple you made that, i was expecting something more
along the lines of Franks and the headache that follwed trying to
understand it, but now, ..wow. Very impressed.

Thankyou once again Bob for another on the ball answer.

Frank, what can i say, the guy on the motorbike will usually win the
marathon.

CAA


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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default A unique ID for protection?

Excellent stuff Bob.

I'm amazed how simple you made that, i was expecting something more
along the lines of Franks and the headache that follwed trying to
understand it, but now, ..wow. Very impressed.

Thankyou once again Bob for another on the ball answer.

Frank, what can i say, the guy on the motorbike will usually win the
marathon.


lol
hat's really a got methapher
Regards
Frank
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default A unique ID for protection?

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/



  #10   Report Post  
Posted to microsoft.public.excel.programming
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/






  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default A unique ID for protection?

Steve Garman wrote:
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.


Sorry, that should have more properly been:

strVolName = String$(cMaxPath, Chr$(0))
strFileSysName = String$(cMaxPath, Chr$(0))

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default A unique ID for protection?

If it makes you feel any better, Frank, Bob's nasty code doesn't work
here. :-)

We disable WSH at ever reboot.

Getting it to die is another matter though.

Frank Kabel wrote:

Hi Bob
this is not fair
I had the same idea but my code is much longer :-)

--
Regards
Frank Kabel
Frankfurt, Germany


Bob Phillips wrote:

Here is one way, get the C drive volume number

Function DiskVolumeId() As String
Dim FSO As Object

Set FSO = CreateObject("Scripting.FileSystemObject")
DiskVolumeId = Format(CDbl(FSO.Drives("C:").SerialNumber))
End Function


"CAA " wrote in message
...

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/




  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default A unique ID for protection?


Hi Steve
you made my day <vbg

Steve Garman wrote:
If it makes you feel any better, Frank, Bob's nasty code doesn't work
here. :-)

We disable WSH at ever reboot.

Getting it to die is another matter though.

Frank Kabel wrote:

Hi Bob
this is not fair
I had the same idea but my code is much longer :-)

--
Regards
Frank Kabel
Frankfurt, Germany


Bob Phillips wrote:

Here is one way, get the C drive volume number

Function DiskVolumeId() As String
Dim FSO As Object

Set FSO = CreateObject("Scripting.FileSystemObject")
DiskVolumeId = Format(CDbl(FSO.Drives("C:").SerialNumber))
End Function


"CAA " wrote in message
...

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/


  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default A unique ID for protection?

Steve - Thanks much - in now makes sense.
It's always amazes me how we can spend so much time on such small issues
Thanks again
  #15   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Data Protection Best Practice: AKA: Real Sheet Protection Mushman(Woof!)[_2_] Excel Discussion (Misc queries) 4 December 30th 09 01:20 AM
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
Filer for unique records and return all column data for unique rec bseeley Excel Discussion (Misc queries) 1 September 12th 09 12:17 AM
How to pick out unique components in a list with unique and common iksuinje Excel Discussion (Misc queries) 2 August 20th 08 09:57 PM
Attempting to sort unique/only count first record in each unique g MJW[_2_] Excel Discussion (Misc queries) 3 August 10th 07 02:56 PM


All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"