Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

protecting software to run only on one computer in vb.net

I have developed a small application and now i want to protect it.

I want to run it only on my own computer and i have developed it for myself.

How can i do that?

like image 410
Web Worm Avatar asked Dec 18 '22 02:12

Web Worm


2 Answers

A. Don't publish it.
B. Hard-code your computer name in the code, and make the first thing the program does to be verifying that System.Environment.MachineName matches it.

like image 132
Jay Avatar answered Jan 20 '23 01:01

Jay


You could always check the processor ID or motherboard serial number.

Private Function SystemSerialNumber() As String
    ' Get the Windows Management Instrumentation object.
    Dim wmi As Object = GetObject("WinMgmts:")

    ' Get the "base boards" (mother boards).
    Dim serial_numbers As String = ""
    Dim mother_boards As Object = _
        wmi.InstancesOf("Win32_BaseBoard")
    For Each board As Object In mother_boards
        serial_numbers &= ", " & board.SerialNumber
    Next board
    If serial_numbers.Length > 0 Then serial_numbers = _
        serial_numbers.Substring(2)

    Return serial_numbers
End Function


Private Function CpuId() As String
    Dim computer As String = "."
    Dim wmi As Object = GetObject("winmgmts:" & _
        "{impersonationLevel=impersonate}!\\" & _
        computer & "\root\cimv2")
    Dim processors As Object = wmi.ExecQuery("Select * from " & _
        "Win32_Processor")

    Dim cpu_ids As String = ""
    For Each cpu As Object In processors
        cpu_ids = cpu_ids & ", " & cpu.ProcessorId
    Next cpu
    If cpu_ids.Length > 0 Then cpu_ids = _
        cpu_ids.Substring(2)

    Return cpu_ids
End Function

Was taken from where: http://www.vb-helper.com/howto_net_get_cpu_serial_number_id.html

Here's a question by Jim to convert this for Option Strict.

like image 35
the_lotus Avatar answered Jan 20 '23 02:01

the_lotus