Results 1 to 8 of 8

Thread: How to lock my app

  1. #1
    New Member
    Join Date
    Feb 09
    Posts
    8

    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

  2. #2
    Addicted Member
    Join Date
    Jan 02
    Location
    UK, Suffolk
    Posts
    231

    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.
    My Free .NET Controls at www.qiosdevsuite.com Includes 30 Controls, Ribbon Toolbar, Ribbon Form etc...
    If your interested in being part of the dev team as volunteer and help keep this product free then please contact me via the 'About Us' Page on QDevSuite

    Useful controls
    Outlook Calendar, Object Listview

  3. #3
    New Member
    Join Date
    Feb 09
    Posts
    8

    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 ?

  4. #4
    Member
    Join Date
    Aug 12
    Posts
    41

    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

  5. #5
    New Member
    Join Date
    Feb 09
    Posts
    8

    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 ?

  6. #6
    Addicted Member
    Join Date
    Jan 02
    Location
    UK, Suffolk
    Posts
    231

    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
    My Free .NET Controls at www.qiosdevsuite.com Includes 30 Controls, Ribbon Toolbar, Ribbon Form etc...
    If your interested in being part of the dev team as volunteer and help keep this product free then please contact me via the 'About Us' Page on QDevSuite

    Useful controls
    Outlook Calendar, Object Listview

  7. #7
    Member
    Join Date
    Aug 12
    Posts
    41

    Re: How to lock my app

    sure

  8. #8
    New Member
    Join Date
    Feb 09
    Posts
    8

    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
  •