Unique ID/Name for a computer?

G

Guest

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
 
H

Harlan Grove

Warren said:
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?

What do you want to do with this? Identify a particular machine each time
your workbook is opened on it? Something else?

If IP numbers are dynamically assigned, then a particular IP number may be
assigned to PC A one day and PC X another day. Only if your users all have
static IP numbers (very unlikely for desktops in most Windows networks)
would IP number identify the same PC all the time.

One way to identify the same C: drive between sessions would be to use Shell
to run the command processor's DIR command redirected to a temporary file,
then read the disk serial number from that file using VBA's Open, Input and
Close statements.
 
R

Rob van Gelder

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
 
G

Guest

The reason I want to do this is this: after the file has been 1) loaded onto the target PC harddrive AND 2) opened, if the file is then copied to someone else's PC, it will not be fully functional because I want the progam (VBA) to determine that it has already been opened. If it does determine that, it will render the spreadsheet less than fully functional

I know this is approach is not fool-proof but I also implemented the following rules to my procedures: when I send the file out, it has the users name at the top of the main sheet showing who the file belongs to with the idea that it will reduce the desire for someone to give a copy to another person before the person I send it to opens it

Another procedure rule I've implemented to tighten the security on this file is that each time the file is opened, it is opened using a set of randomly generated passwords from the previous time it was opened. Obviously the first time it is opened, it is opened without the need for passwords but once opened it is immedialy secured with brand new randomly created passwords - ain't pretty but seems to work. In summary, Here are the steps regarding my password methods..
OPENING THE FILE..
1) ...the first time without VBA using passwords (one-time). I send the file without password protection
2) VBA immediatly applies passwords by using radomly generated passwords from functions on a hidden sheet
3) VBA then password-protects the workbook and all the sheets using the new passwords
CLOSING THE FILE..
4) VBA resets the disable switch to ON
6) VBA resets the passwords again using the random generated procedure again (same as #2 above
7) VBA force saves the file
8) file is closed
-Warre

----- Harlan Grove wrote: ----

Warren said:
1) Is there a way to identify a PC that excel is running on? I.e., I
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

What do you want to do with this? Identify a particular machine each tim
your workbook is opened on it? Something else

If IP numbers are dynamically assigned, then a particular IP number may b
assigned to PC A one day and PC X another day. Only if your users all hav
static IP numbers (very unlikely for desktops in most Windows networks
would IP number identify the same PC all the time

One way to identify the same C: drive between sessions would be to use Shel
to run the command processor's DIR command redirected to a temporary file
then read the disk serial number from that file using VBA's Open, Input an
Close statements
 
G

Guest

How do I call another macro (with your code) from my AUTO_OPEN macro? (I am just learning VBA
Thanks again in advance
-Warre

----- Rob van Gelder wrote: ----

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

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

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

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

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

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

MsgBox strTem
End Su
 
T

Tushar Mehta

Ummm...

You have some very elaborate plans for protecting your product, but if
you are just learning VBA what are you protecting? Wouldn't you be
better off learning VBA first and then worrying about how to protect
your work? Of course, you know your application better than I do,
so...

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
G

Guest

Thanks for your reply Tushar

I am trying to learn VBA but in the very short-term I have this tool that is being used by quite a few insurance agents who have encouraged me to sell it. I think the market for this tool is rather small - not expecting to make a lot of $$ - more like a challenge

My question regarding Rob van Gelder's code is this: I'm not sure how to place the code. At this point, the extent of my VBA experience is AUTO_OPEN and AUTO_CLOSE. I would like to call his code from AUTO_OPEN, but do I create a standard module or class modue. What is your suggestions for laying this out

Do you have any suggested VBA reading for beginners that is easy to read

Thank
-Warren

----- Tushar Mehta wrote: ----

Ummm..

You have some very elaborate plans for protecting your product, but if
you are just learning VBA what are you protecting? Wouldn't you be
better off learning VBA first and then worrying about how to protect
your work? Of course, you know your application better than I do,
so..

--
Regards

Tushar Meht
www.tushar-mehta.co
Excel, PowerPoint, and VBA add-ins, tutorial
Custom MS Office productivity solution
 
T

Tushar Mehta

To answer your specific question, put Rob's code in a standard module.
To execute a subroutine named Test from some other code, use the
statement

Test

Books on VBA? I'd say a trip to the local library or book store is
called for. Browse through the selection and pick something that makes
sense to you.

Finally, XL is not designed for the development of secure solutions.
Any scheme you develop will be almost trivial to defeat. But, it's
your decision...

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
R

Rob van Gelder

Tushar's comments are valid. Excel's protection is easily defeated. That
said, I believe most protection is easily defeated. You only need go to a
crack site (google for crackz) to discover that copy protection is a
challenging game and to some people.

If you just want to put a "discouraging" lock in place, then Excel and VBA
protection will work fine. It won't protect against the determined, that's
all.

As for the code - in a standard module:

Sub Auto_Open()
test
End Sub

Sub test()
...
End Sub


Suggest you do some reading in Help. A good place to read as follows:
From VBA's menu: Help | Microsoft Visual Basic Help
Visual Basic Conceptual Topics: Calling Sub and Function Procedures



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


Tushar Mehta said:
To answer your specific question, put Rob's code in a standard module.
To execute a subroutine named Test from some other code, use the
statement

Test

Books on VBA? I'd say a trip to the local library or book store is
called for. Browse through the selection and pick something that makes
sense to you.

Finally, XL is not designed for the development of secure solutions.
Any scheme you develop will be almost trivial to defeat. But, it's
your decision...

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
that is being used by quite a few insurance agents who have encouraged me to
sell it. I think the market for this tool is rather small - not expecting
to make a lot of $$ - more like a challenge.to place the code. At this point, the extent of my VBA experience is
AUTO_OPEN and AUTO_CLOSE. I would like to call his code from AUTO_OPEN, but
do I create a standard module or class modue. What is your suggestions for
laying this out?
 
H

Harlan Grove

Warren said:
The reason I want to do this is this: after the file has been 1) loaded
onto the target PC harddrive AND 2) opened, if the file is then copied
to someone else's PC, it will not be fully functional because I want the
progam (VBA) to determine that it has already been opened. If it does
determine that, it will render the spreadsheet less than fully functional.
....

If you just want to discourage file copying, original distribution with
static password protection should be sufficient. That'll be enough to
prevent unsophisticated users from altering your file. As for sophisticated
users, take a look at all the responses in the Excel newsgroups about
available passwork crackers. It'd take maybe 2 seconds to remove all the
dynamically created random passwords you're thinking about adding. 2
seconds! After which time it'd be child's play to search & destroy all the
protective macro code you think is protecting your model.

Final comment: just speaking for myself, I don't think any software
distributed as Excel files is worth anything. Either you're providing a
service of some worth, and all files including .XLS ones are merely adjunct
to the service, or you're providing a product, in which case .XLS file
distribution isn't exactly the hallmark of professional development.
 
G

Guest

Rob & Tushar:
Thanks for your help. I've got it working. You're right about the security. I'm just trying to discourage it as best I can. There is no sensitive data in there - only pricing data that insurance agents see everyday
-Warren R

----- Rob van Gelder wrote: ----


Tushar's comments are valid. Excel's protection is easily defeated. Tha
said, I believe most protection is easily defeated. You only need go to
crack site (google for crackz) to discover that copy protection is
challenging game and to some people

If you just want to put a "discouraging" lock in place, then Excel and VB
protection will work fine. It won't protect against the determined, that'
all

As for the code - in a standard module

Sub Auto_Open(
tes
End Su

Sub test(
..
End Su


Suggest you do some reading in Help. A good place to read as follows
From VBA's menu: Help | Microsoft Visual Basic Hel
Visual Basic Conceptual Topics: Calling Sub and Function Procedure



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


Tushar Mehta said:
To answer your specific question, put Rob's code in a standard module
To execute a subroutine named Test from some other code, use th
statemen
Tes
Books on VBA? I'd say a trip to the local library or book store i
called for. Browse through the selection and pick something that make
sense to you
Finally, XL is not designed for the development of secure solutions
Any scheme you develop will be almost trivial to defeat. But, it'
your decision..
-- Regards
Tushar Meht
www.tushar-mehta.co
Excel, PowerPoint, and VBA add-ins, tutorial
Custom MS Office productivity solutionthat is being used by quite a few insurance agents who have encouraged me t
sell it. I think the market for this tool is rather small - not expectin
to make a lot of $$ - more like a challengeto place the code. At this point, the extent of my VBA experience i
AUTO_OPEN and AUTO_CLOSE. I would like to call his code from AUTO_OPEN, bu
do I create a standard module or class modue. What is your suggestions fo
laying this out
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top