473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Computer Name - Best way to obtain this VB.Net

Thanks for your tolerance on this list. I asked the question regarding
Commercial Copy Protection along with Unique PC Idnetifier and obtaining the
active IP address. This was all to identify and tie down software to each PC
on a network. I have just realised that the unique identity that I need to
go for on the network and should be easy to get in a foolproof manner is the
computer name. Hence which method will ALWAYS return the computer name on
any XP Win2K or Vista machine - 100% of the time??

Best wishes and thanks
Paul Bromley
Dec 10 '06 #1
8 11342
I assume that this is likely to be the best way? :-

mComputerNetBiosName = System.Environment.MachineName

Best wishes

Paul Bromley
"Paul Bromley" <fl*******@dsl.pipex.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Thanks for your tolerance on this list. I asked the question regarding
Commercial Copy Protection along with Unique PC Idnetifier and obtaining
the active IP address. This was all to identify and tie down software to
each PC on a network. I have just realised that the unique identity that I
need to go for on the network and should be easy to get in a foolproof
manner is the computer name. Hence which method will ALWAYS return the
computer name on any XP Win2K or Vista machine - 100% of the time??

Best wishes and thanks
Paul Bromley

Dec 10 '06 #2
Paul Bromley wrote:
I assume that this is likely to be the best way? :-

mComputerNetBiosName = System.Environment.MachineName
Yes, you're correct with this.

I've followed your other posts and would like to suggest that generating
a unique Serial Number for your software, on each machine that it is
executed, is not that difficult.

I use the following code (watch for wrapping!) -

Imports System.Management

''' <summary>
''' String of 1 to 2 chars. eg. "C" or "C:".
''' </summary>
''' <param name="sDriveLetter"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function GetDriveSerialNumber(ByVal sDriveLetter As String) As String

If Len(sDriveLetter) = 1 Then
sDriveLetter &= ":"
Else
sDriveLetter = Strings.Left(Environment.SystemDirectory, 2)
End If

Dim HardDiskInfo As New ManagementObject("Win32_LogicalDisk.DeviceID="
& ChrW(34) & sDriveLetter & ChrW(34))
Dim HardDiskProperty As PropertyData =
HardDiskInfo.Properties("VolumeSerialNumber")
Return HardDiskProperty.Value.ToString

End Function
I first obtain the Drive Serial Number and then ensure it is
8-Characters in length -

Dim sA As String =
GetDriveSerialNumber(Strings.Left(Environment.Syst emDirectory, 2))

Dim N As UInt16 = Len(sA)
If N < 8 Then
sA = sA.PadRight(8 - N, "0")
ElseIf N 8 Then
sA = Strings.Left(sA, 8) 'Truncate to 8 Chars.
End If
After this I "AND" the value with another routine that automatically
generates an 8-Character HEX number based on the title of my software.
I then end up with a 16-Character HEX number, which is unique to each of
my applications and unique on every computer, I then do some more
XOR'ing and present this to the User as the Application Serial Number.

I obviously have another application that reverses all of this to
provide an Unlock Code that the User enters.

There are literally hundreds of Users running my applications using this
method, and although it really only stops the honest pirates, it serves
my purposes well.

If you'd like to see an example, please download one of my apps (written
for specific clients) from the following site -

http://www.arnfieldcomputerservices....pi/publish.htm

This will provide an example of what my Registration Screen looks like.

If you require any further assistance, please feel free to contact me
direct via the email address used in this post.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Dec 10 '06 #3
Many thanks for this Shane - I will take a look tomorrow. Has this worked OK
on Win2K as well as XP?

Best wishes

Paul Bromley
"ShaneO" <sp****@optusnet.com.auwrote in message
news:45***********************@news.optusnet.com.a u...
Paul Bromley wrote:
>I assume that this is likely to be the best way? :-

mComputerNetBiosName = System.Environment.MachineName

Yes, you're correct with this.

I've followed your other posts and would like to suggest that generating a
unique Serial Number for your software, on each machine that it is
executed, is not that difficult.

I use the following code (watch for wrapping!) -

Imports System.Management

''' <summary>
''' String of 1 to 2 chars. eg. "C" or "C:".
''' </summary>
''' <param name="sDriveLetter"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function GetDriveSerialNumber(ByVal sDriveLetter As String) As
String

If Len(sDriveLetter) = 1 Then
sDriveLetter &= ":"
Else
sDriveLetter = Strings.Left(Environment.SystemDirectory, 2)
End If

Dim HardDiskInfo As New ManagementObject("Win32_LogicalDisk.DeviceID=" &
ChrW(34) & sDriveLetter & ChrW(34))
Dim HardDiskProperty As PropertyData =
HardDiskInfo.Properties("VolumeSerialNumber")
Return HardDiskProperty.Value.ToString

End Function
I first obtain the Drive Serial Number and then ensure it is 8-Characters
in length -

Dim sA As String =
GetDriveSerialNumber(Strings.Left(Environment.Syst emDirectory, 2))

Dim N As UInt16 = Len(sA)
If N < 8 Then
sA = sA.PadRight(8 - N, "0")
ElseIf N 8 Then
sA = Strings.Left(sA, 8) 'Truncate to 8 Chars.
End If
After this I "AND" the value with another routine that automatically
generates an 8-Character HEX number based on the title of my software. I
then end up with a 16-Character HEX number, which is unique to each of my
applications and unique on every computer, I then do some more XOR'ing and
present this to the User as the Application Serial Number.

I obviously have another application that reverses all of this to provide
an Unlock Code that the User enters.

There are literally hundreds of Users running my applications using this
method, and although it really only stops the honest pirates, it serves my
purposes well.

If you'd like to see an example, please download one of my apps (written
for specific clients) from the following site -

http://www.arnfieldcomputerservices....pi/publish.htm

This will provide an example of what my Registration Screen looks like.

If you require any further assistance, please feel free to contact me
direct via the email address used in this post.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.

Dec 11 '06 #4
Paul Bromley wrote:
Many thanks for this Shane - I will take a look tomorrow. Has this worked OK
on Win2K as well as XP?

Yes, this works on both Win2K and XP. It also works on Windows Server
2000 + 2003. I haven't tested it on Win98, but I believe if it can run
the .NET Framework then it will work.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Dec 11 '06 #5
Shane,

Not all drives have serialnumbers.

Cor

"ShaneO" <sp****@optusnet.com.auschreef in bericht
news:45**********************@news.optusnet.com.au ...
Paul Bromley wrote:
>Many thanks for this Shane - I will take a look tomorrow. Has this worked
OK on Win2K as well as XP?

Yes, this works on both Win2K and XP. It also works on Windows Server
2000 + 2003. I haven't tested it on Win98, but I believe if it can run
the .NET Framework then it will work.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.

Dec 11 '06 #6
Cor Ligthert [MVP] wrote:
Shane,

Not all drives have serialnumbers.

Cor
Cor, yes I've read that and certainly don't dispute it, however in my
experience (so far) I haven't found it to be the case.

Looking at my code sample, what do you believe would be returned in this
case? Under what circumstances are Serial Numbers not available?

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Dec 11 '06 #7
Hi Paul

You could also use the MAC address as this is specific to the NIC card
(as far as I understand) and has to be unique on the same network.

As a failsafe to the code that's posted here for getting the serial
number of the harddrive, you could use a combination of the MAC address
and the harddrive serial - that way, if the drive doesn't have a serial
then you can use the MAC address.

There's plenty of code available for getting the MAC address should you
need it.

Martin

Paul Bromley wrote:
Many thanks for this Shane - I will take a look tomorrow. Has this worked OK
on Win2K as well as XP?

Best wishes

Paul Bromley
"ShaneO" <sp****@optusnet.com.auwrote in message
news:45***********************@news.optusnet.com.a u...
Paul Bromley wrote:
I assume that this is likely to be the best way? :-

mComputerNetBiosName = System.Environment.MachineName
Yes, you're correct with this.

I've followed your other posts and would like to suggest that generating a
unique Serial Number for your software, on each machine that it is
executed, is not that difficult.

I use the following code (watch for wrapping!) -

Imports System.Management

''' <summary>
''' String of 1 to 2 chars. eg. "C" or "C:".
''' </summary>
''' <param name="sDriveLetter"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function GetDriveSerialNumber(ByVal sDriveLetter As String) As
String

If Len(sDriveLetter) = 1 Then
sDriveLetter &= ":"
Else
sDriveLetter = Strings.Left(Environment.SystemDirectory, 2)
End If

Dim HardDiskInfo As New ManagementObject("Win32_LogicalDisk.DeviceID=" &
ChrW(34) & sDriveLetter & ChrW(34))
Dim HardDiskProperty As PropertyData =
HardDiskInfo.Properties("VolumeSerialNumber")
Return HardDiskProperty.Value.ToString

End Function
I first obtain the Drive Serial Number and then ensure it is 8-Characters
in length -

Dim sA As String =
GetDriveSerialNumber(Strings.Left(Environment.Syst emDirectory, 2))

Dim N As UInt16 = Len(sA)
If N < 8 Then
sA = sA.PadRight(8 - N, "0")
ElseIf N 8 Then
sA = Strings.Left(sA, 8) 'Truncate to 8 Chars.
End If
After this I "AND" the value with another routine that automatically
generates an 8-Character HEX number based on the title of my software. I
then end up with a 16-Character HEX number, which is unique to each of my
applications and unique on every computer, I then do some more XOR'ing and
present this to the User as the Application Serial Number.

I obviously have another application that reverses all of this to provide
an Unlock Code that the User enters.

There are literally hundreds of Users running my applications using this
method, and although it really only stops the honest pirates, it serves my
purposes well.

If you'd like to see an example, please download one of my apps (written
for specific clients) from the following site -

http://www.arnfieldcomputerservices....pi/publish.htm

This will provide an example of what my Registration Screen looks like.

If you require any further assistance, please feel free to contact me
direct via the email address used in this post.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Dec 11 '06 #8
Thanks for all of the feedback on this and my recent posts. I have decided
to go with computer name and to use this along with other strings in an
encrypted format to produce my registartion keys. This will be more than
adequate for my purposes, as I do not want to make life difficult ofr my
users, but just want to preevent them from making multpile unpaid installs
on the same network.

Best wishes,
Paul Bromley

"Pritcham" <do******************@hotmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
Hi Paul

You could also use the MAC address as this is specific to the NIC card
(as far as I understand) and has to be unique on the same network.

As a failsafe to the code that's posted here for getting the serial
number of the harddrive, you could use a combination of the MAC address
and the harddrive serial - that way, if the drive doesn't have a serial
then you can use the MAC address.

There's plenty of code available for getting the MAC address should you
need it.

Martin

Paul Bromley wrote:
>Many thanks for this Shane - I will take a look tomorrow. Has this worked
OK
on Win2K as well as XP?

Best wishes

Paul Bromley
"ShaneO" <sp****@optusnet.com.auwrote in message
news:45***********************@news.optusnet.com. au...
Paul Bromley wrote:
I assume that this is likely to be the best way? :-

mComputerNetBiosName = System.Environment.MachineName
Yes, you're correct with this.

I've followed your other posts and would like to suggest that
generating a
unique Serial Number for your software, on each machine that it is
executed, is not that difficult.

I use the following code (watch for wrapping!) -

Imports System.Management

''' <summary>
''' String of 1 to 2 chars. eg. "C" or "C:".
''' </summary>
''' <param name="sDriveLetter"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function GetDriveSerialNumber(ByVal sDriveLetter As String) As
String

If Len(sDriveLetter) = 1 Then
sDriveLetter &= ":"
Else
sDriveLetter = Strings.Left(Environment.SystemDirectory, 2)
End If

Dim HardDiskInfo As New ManagementObject("Win32_LogicalDisk.DeviceID="
&
ChrW(34) & sDriveLetter & ChrW(34))
Dim HardDiskProperty As PropertyData =
HardDiskInfo.Properties("VolumeSerialNumber")
Return HardDiskProperty.Value.ToString

End Function
I first obtain the Drive Serial Number and then ensure it is
8-Characters
in length -

Dim sA As String =
GetDriveSerialNumber(Strings.Left(Environment.Syst emDirectory, 2))

Dim N As UInt16 = Len(sA)
If N < 8 Then
sA = sA.PadRight(8 - N, "0")
ElseIf N 8 Then
sA = Strings.Left(sA, 8) 'Truncate to 8 Chars.
End If
After this I "AND" the value with another routine that automatically
generates an 8-Character HEX number based on the title of my software.
I
then end up with a 16-Character HEX number, which is unique to each of
my
applications and unique on every computer, I then do some more XOR'ing
and
present this to the User as the Application Serial Number.

I obviously have another application that reverses all of this to
provide
an Unlock Code that the User enters.

There are literally hundreds of Users running my applications using
this
method, and although it really only stops the honest pirates, it serves
my
purposes well.

If you'd like to see an example, please download one of my apps
(written
for specific clients) from the following site -

http://www.arnfieldcomputerservices....pi/publish.htm

This will provide an example of what my Registration Screen looks like.

If you require any further assistance, please feel free to contact me
direct via the email address used in this post.

ShaneO

There are 10 kinds of people - Those who understand Binary and those
who
don't.

Dec 12 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Matt | last post by:
Hi everybody, does anyone know how to retrieve the computer name using ASP? cheers...
4
by: Dr. StrangeDub | last post by:
Leaving network identification/DNS out of the picture, how does one change the name of a computer in a local Workgroup (in C#)? I implemented the SetComputerName() API call and that only seems to...
0
by: memememe | last post by:
I want to modify the computer name (the one used on netbios) before the configuration is read by netbios. I alreayd have a service that does this and I have created dependencies on this server for...
1
by: Uzi Baruch | last post by:
Hi! i want to know if i have an ip address of a computer and its DNS server name, if their is an windows API that can resolve the computer name of the given ip address. or vice verca -...
5
by: z. f. | last post by:
i need to get the computer name from an aspx page. i use System.Windows.Forms.SystemInformation.ComputerName() and it's working fine, but in second thought, it might not be recomended to use the...
5
by: ThunderMusic | last post by:
Hi, I want to find the computer name and the company name from the network indentification informations. For the computer name, I found System.Net.Dns.GetHostName(), but I fgound nothing for...
0
by: solisjw | last post by:
I received the error "Computer name could not be obtain" when i run a winservice that uses a proxy to run some application. Sorry my english..! Exception Details:...
0
by: BrianT | last post by:
I'm trying to build code that allows the computer name to be changed, then asks the user to reboot to make the change affective. I got the code working when logged in as the local computer...
1
by: kartik369 | last post by:
This code gets the IP address from the computer name we already know. I wanted to know how can we get the computer name if we know the IP address. Thanks void AsyncServer::InitSocks() {...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.