473,545 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11360
I assume that this is likely to be the best way? :-

mComputerNetBio sName = System.Environm ent.MachineName

Best wishes

Paul Bromley
"Paul Bromley" <fl*******@dsl. pipex.comwrote in message
news:%2******** ********@TK2MSF TNGP02.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? :-

mComputerNetBio sName = System.Environm ent.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.Manageme nt

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

If Len(sDriveLette r) = 1 Then
sDriveLetter &= ":"
Else
sDriveLetter = Strings.Left(En vironment.Syste mDirectory, 2)
End If

Dim HardDiskInfo As New ManagementObjec t("Win32_Logica lDisk.DeviceID= "
& ChrW(34) & sDriveLetter & ChrW(34))
Dim HardDiskPropert y As PropertyData =
HardDiskInfo.Pr operties("Volum eSerialNumber")
Return HardDiskPropert y.Value.ToStrin g

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

Dim sA As String =
GetDriveSerialN umber(Strings.L eft(Environment .SystemDirector y, 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****@optusne t.com.auwrote in message
news:45******** *************** @news.optusnet. com.au...
Paul Bromley wrote:
>I assume that this is likely to be the best way? :-

mComputerNetBi osName = System.Environm ent.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.Manageme nt

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

If Len(sDriveLette r) = 1 Then
sDriveLetter &= ":"
Else
sDriveLetter = Strings.Left(En vironment.Syste mDirectory, 2)
End If

Dim HardDiskInfo As New ManagementObjec t("Win32_Logica lDisk.DeviceID= " &
ChrW(34) & sDriveLetter & ChrW(34))
Dim HardDiskPropert y As PropertyData =
HardDiskInfo.Pr operties("Volum eSerialNumber")
Return HardDiskPropert y.Value.ToStrin g

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

Dim sA As String =
GetDriveSerialN umber(Strings.L eft(Environment .SystemDirector y, 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****@optusne t.com.auschreef in bericht
news:45******** **************@ news.optusnet.c om.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****@optusne t.com.auwrote in message
news:45******** *************** @news.optusnet. com.au...
Paul Bromley wrote:
I assume that this is likely to be the best way? :-

mComputerNetBio sName = System.Environm ent.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.Manageme nt

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

If Len(sDriveLette r) = 1 Then
sDriveLetter &= ":"
Else
sDriveLetter = Strings.Left(En vironment.Syste mDirectory, 2)
End If

Dim HardDiskInfo As New ManagementObjec t("Win32_Logica lDisk.DeviceID= " &
ChrW(34) & sDriveLetter & ChrW(34))
Dim HardDiskPropert y As PropertyData =
HardDiskInfo.Pr operties("Volum eSerialNumber")
Return HardDiskPropert y.Value.ToStrin g

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

Dim sA As String =
GetDriveSerialN umber(Strings.L eft(Environment .SystemDirector y, 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******** *************@j 72g2000cwa.goog legroups.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****@optusne t.com.auwrote in message
news:45******* *************** *@news.optusnet .com.au...
Paul Bromley wrote:
I assume that this is likely to be the best way? :-

mComputerNetBi osName = System.Environm ent.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.Manageme nt

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

If Len(sDriveLette r) = 1 Then
sDriveLetter &= ":"
Else
sDriveLetter = Strings.Left(En vironment.Syste mDirectory, 2)
End If

Dim HardDiskInfo As New ManagementObjec t("Win32_Logica lDisk.DeviceID= "
&
ChrW(34) & sDriveLetter & ChrW(34))
Dim HardDiskPropert y As PropertyData =
HardDiskInfo.Pr operties("Volum eSerialNumber")
Return HardDiskPropert y.Value.ToStrin g

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

Dim sA As String =
GetDriveSerialN umber(Strings.L eft(Environment .SystemDirector y, 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
5461
by: Matt | last post by:
Hi everybody, does anyone know how to retrieve the computer name using ASP? cheers...
4
14277
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 change the NetBIOS Computer Name. I've verified that the underlying registry key value that gets changed is: ...
0
1033
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 services such as netbios helper, ipsec, tcpip, etc. So in theory those services dont start before my service runs and changes the values on...
1
18737
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 - given a computer name and it's DNS server, i need to obtain the IP address.
5
4285
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 system.windows.forms.dll inside an asp-dot-net code. any information here will help. TIA, z.
5
2285
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 the company name. Can someone help me plz? Thanks
0
1381
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: System.InvalidOperationException: Computer name could not be obtained. Somebody knows how to solve it?? Regards...!
0
1881
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 administrator or a domain administrator, but a regular domain user (with administrator privileges on the local machine) can't run the code successfully. They...
1
5506
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() { String* server = "CATUXPSD01"; int port = 4901; printf("in InitSocks"); String* request = String::Concat(S"Our test data asdf");
0
7682
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7935
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7449
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6009
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5351
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.