|
-
Aug 29th, 2012, 03:39 AM
#1
Thread Starter
New Member
How to lock my app
Hello my friends
I have created a vb portable application and i want to make it work only on the pc that (the usb) is plugged in for the first time.
Something like when you plug the usb flash memory on your pc the app autostarts , auto-self registers and after that if u try to plug it on another computer it will not work.
Any ideas?
Thank you
-
Aug 29th, 2012, 04:58 AM
#2
Hyperactive Member
Re: How to lock my app
Here is 1 idea, get a hardware Id (motherboard id, processor id etc..) and store this value on first run. Then next time the application starts, it can compare these values to see if its still the same machine.
-
Aug 29th, 2012, 05:08 AM
#3
Thread Starter
New Member
Re: How to lock my app
That would do the trick. Where should i store this value? Do i need to create somekind of .ini file and encrypt the id inthere or is there any simplier-faster way ?
-
Aug 29th, 2012, 05:13 AM
#4
Member
Re: How to lock my app
I have an idea
Make a autorun file (just google that to find out how it's done)
Then create a setting called "lockdown" and save it as string with the default value of "".
Add this code to the loading event of your first form (probably Form1)
Code:
If My.Settings.lockdown = "" then
My.Settings.lockdown = My.Computer.Name
End If
'Checks if the variable is the same as the computer name
'The (Not) is there for inverting the result, so if this=> My.Settings.lockdown = My.Computer.Name is true, it will act as if it's false and the other way around.
If Not(My.Settings.lockdown = My.Computer.Name) Then
Application.Exit()
'Exits the application if the (lockdown) setting and the computer name aren't the same
End If
Is this what you were looking for?
Regards,
suzi9spal
-
Aug 29th, 2012, 05:29 AM
#5
Thread Starter
New Member
Re: How to lock my app
Thanx suzi9spal
I think this is what i am looking for . Instead of My.Computer.Name i gues i can store the MAC address too ?
-
Aug 29th, 2012, 06:57 AM
#6
Hyperactive Member
Re: How to lock my app
I wouldn't use mycomputer.name as this can be changed. The below code will give you CPUid and Motherboard.
Code:
Public HWID As String = GetCPUId() & GetSerialNumber()
Private Function GetCPUId() As String
Dim qry As New SelectQuery("Win32_Processor")
Dim CPUId(0) As String
Dim searchString As New ManagementObjectSearcher(qry)
Dim info As ManagementObject
For Each info In searchString.Get()
ReDim Preserve CPUId(CPUId.Length)
CPUId(CPUId.Length - 1) = String.Format("{0}", info("ProcessorId").ToString())
Next
Return CPUId(1)
End Function
Private Function GetSerialNumber() As String
Dim qry As New SelectQuery("Win32_BaseBoard")
Dim SerialNumber(0) As String
Dim searchString As New ManagementObjectSearcher(qry)
Dim info As ManagementObject
For Each info In searchString.Get()
ReDim Preserve SerialNumber(SerialNumber.Length)
SerialNumber(SerialNumber.Length - 1) = String.Format("{0}", info("SerialNumber").ToString())
Next
Return SerialNumber(1)
End Function
-
Aug 29th, 2012, 10:31 AM
#7
Member
-
Aug 30th, 2012, 12:04 AM
#8
Thread Starter
New Member
Re: How to lock my app
Hello friends again
I tryed what you suggested me but there is a problem. The app.config file is saved in path : C:\Users\Administrator\AppData\Local\Temp\(MyAppName)\app.config.
My app should be working portable , the .config file should be relocated into the flash drive. How do i configure that?
What happens now is : every time i plug the usb flash into a computer and i run my app a new app.config file is created . The goal is to have the app.config file stored into the flash drive and every time that i tun my app on a different pc it should recognise that it is not the one that it was plugged in for first time and it should stop working.
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|