Posted on 2005-05-08
Medium Priority
Last Modified: 2010-04-23
I have written a VB.NET 2003 application which I would like to reduce the possibilities of people making illegal copies. Therefore, I wrote some code that when the program is run for the first time, it gererates a random code. The user must then e-mail or phone me and read this number to me. I then type it into a little program I wrote which performs some simple calculations on it and spits out another code. I then give this to the client to punches it into the program. The program performs the same calculation on the original number, and if it matches the number I gave him, it unlocks the program. It can even unlock the program for a certain number of days (basically extend the trial period) depending on what code I give him. Just two problems:

1. The trial number of days left / unlock status is stored in the registry and can therefore be modified my anyone with some Windows knowledge. What is the best way to encrypt this number?

2. Is there a program or code that does more or less what Windows XP Activation does - where instead of randomly generating a number when the program is run for the first time, it generates a number based on the user's hardware? That way I can tell if he is installing it on another machine if he phones trying to get another unlock key. Also, if he formats and reinstalls the program, the same unlock her from before will still work.

Question by:SETP
LVL 21

Assisted Solution

oleggold earned 450 total points
ID: 13954897
> generates a number based on the user's hardware
Try this:
Hope It helps
LVL 14

Assisted Solution

amyhxu earned 450 total points
ID: 13954985

Accepted Solution

jarnsater earned 600 total points
ID: 14085481

I'm currently developing a piece of software that will do a hardware and software inventory of all computers, and what I've found best to use for secure identification is CPU id and BIOS id.

These can be retrieved by using WMI, as in my example below.
WMI is very powerful and can be used to get all available info about the computer.

Check here if you want to know about additional WMI classes available:

Btw, the code below is VB6, but should easily be able to port it to .NET

/ Jon

'Add the following code to a module (called e.g. WMI)
Option Explicit

Private m_mainWmi As Object
Private m_deviceLists As Collection

Private Function GetMainWMIObject() As Object
  On Error GoTo eh
  If m_mainWmi Is Nothing Then
    Set m_mainWmi = GetObject("WinMgmts:")
  End If
  Set GetMainWMIObject = m_mainWmi
  Exit Function
  Set GetMainWMIObject = Nothing
End Function

Public Function WmiIsAvailable() As Boolean
  WmiIsAvailable = CBool(Not GetMainWMIObject Is Nothing)
End Function

Public Function GetWmiDeviceSingleValue(ByVal WmiClass As String, ByVal WmiProperty As String) As String
  On Error GoTo done
  Dim result As String
  Dim wmiclassObjList As Object
  Set wmiclassObjList = GetWmiDeviceList(WmiClass)
  Dim wmiclassObj As Object
  For Each wmiclassObj In wmiclassObjList
    result = CallByName(wmiclassObj, WmiProperty, VbGet)
    Exit For

  GetWmiDeviceSingleValue = Trim(result)
End Function

Public Function GetWmiDeviceList(ByVal WmiClass As String) As Object
  If m_deviceLists Is Nothing Then
    Set m_deviceLists = New Collection
  End If
  On Error GoTo fetchNew
  Set GetWmiDeviceList = m_deviceLists.Item(WmiClass)
  Exit Function
  Dim devList As Object
  Set devList = GetWmiDeviceListInternal(WmiClass)
  If Not devList Is Nothing Then
    Call m_deviceLists.Add(devList, WmiClass)
  End If
  Set GetWmiDeviceList = devList
End Function

Private Function GetWmiDeviceListInternal(ByVal WmiClass As String) As Object
  On Error GoTo eh
  Set GetWmiDeviceListInternal = GetMainWMIObject.Instancesof(WmiClass)
  Exit Function
  Set GetWmiDeviceListInternal = Nothing
End Function


' then anywhere in your program you could write the fllowing to get the id:s

  Dim CPU As String
  CPU = GetWmiDeviceSingleValue("Win32_Processor", "ProcessorID")
  Dim BIOS As String
  BIOS = GetWmiDeviceSingleValue("Win32_BIOS", "SerialNumber")

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question