Paul said:
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.SystemDirectory, 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 -
www.arnfieldcomputerservices.com/apps/spi/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.