Validate License Via Internet from VB App

I have an already existing VB app, that I can modify and add some code, that I wanted to deploy, but need to come up with a solution to validate on-line to allow the application to work. Basically, to validate if a client has paid, let's say, the key would be turned on, and if not, the app key would be turned off.  I can logically create the code, but need some ground-level advice on how and what (and some code) to do this.  What is involved.  Conceptually it seems simple, I have a list of clients, with a flag of 1 or 0 (on/off).  I can update this value at will.  The client app upon runtime, or say every 30 days, goto a designated site, look up the client, see the value, and let it do its thing from there.  Any ideas on what the best approach is, and how to do something like this?  I'm creating a service model for this app.  Thanks!
rsp05Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robberbaron (robr)Commented:
1/ need to have a website that is DB enabled.. costs more
1.1 Create a form there that accepts a UserID as input and returns a passcode to the application.  The VB Web controls should be able to do this.
1.2 The application then compares the returned passcode to the locally stored one.
1.3 If you will be tying this to a machine, then you need a mechanism for identifing each box. So the first time and install is done on a PC, the user will have to enter some detail of the box and get back a valid passcode.
1.4 A hardware key would be best for this latter part as it's more secure, a licence can be shared around the office (one at a time though).  Talking dollars though.

2/ If website is not DB & scripting enabled, then you will have to download a textfile, perhaps based upon the userid , open it and compare contents with passcode.
2.1 this is probably a little more difficult to manage but when licence expires, you can change the webfile so the passcode no longer matches.
2.2 I wouldnt just delete the file as then the user will get a "file not found" error which could be just because the internet is don for them.

my 2c worth.
0
Mark_FreeSoftwareCommented:

the way i would design it, is not to disable the code,
but to remove the code


if you have some code disabled, or a menu item disabled or so,
this can be easily reverse engineered.

when the code is not there (it is in a dll that sits on your server)

it needs to be downloaded before the user can execute the code.


and when can the user download it?
with the right code :)
0
Éric MoreauSenior .Net ConsultantCommented:
that would mean that the application could not be used offline!
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mark_FreeSoftwareCommented:

that would mean the user would validate online, and then the pc can be taken offline
0
rsp05Author Commented:
Thanks, all for reply.
Mark is right, although I would have the app validated every say, 30 days (+ a grace period), and the app would be used offline.  I would require that the user app have access to the internet.
I will study robberbaron's interesting solutions.

I was going to have the validation code compiled in the vb app, and the client info would be in the registry (where it is now).  What is some code sample to goto a web site, read a file, and compare values. Tx
0
rsp05Author Commented:
robberbaron: If I went w/option 2, how would I reference the textfile, just by supplying the path to url?.  I would need to upload a textfile to the site, and call it there?  Code ideas?  Thx
0
Robberbaron (robr)Commented:
1/ You would need to assign each user a licence number xxyyzz (no surprise there) when they paid for app.

2/ You upload a Text or binary file to your web server, named like xxyyyzz.lic.  It can be a binary format decided by you and has expiry date etc encoded within.

3/ When user installs app on their system , they enter the license number. App saves to registry.

4/ When app runs, it gets license number from registry then attempts to connect to INET and retrieve the license file xxyyzz.lic from your website.  The app saves the lic file or just opens stream and decodes data.  App then decides if it is currently licensed to run.

5/ When lic expires, you can delete the lic file from web or simply copy an invalid one in its place. I like the latter as the user will then get a License invalid error rather than lic not found.

-------------------------------------------------
Here is some code i once used to download a couple of files from net using the Internet control

    Dim strURL As String, x As CheckBox
    Dim savefile As String, fln As Long
    Dim b() As Byte
   
   
    For Each x In chkGethistory
        If x.Value = vbChecked Then
           
            ' Set the strURL to a valid address.
            Select Case x.index
                Case 0  'Saturday
                    strURL = URLHistorySat
                    savefile = FileHistorySat
                    'picOut.Print "/"
                    picOut.Print "Sat Hist"
                Case 1  'wednay
                    strURL = URLHistoryWed
                    savefile = FileHistoryWed
                    'picOut.Print "/"
                    picOut.Print "Wed Hist"
                Case 2  '
                    'strURL = URLHistoryPball
            End Select
       
             b() = Inet1.OpenURL(strURL, icByteArray)
            picOut.Print "/";
            fln = FreeFile
            Open savefile For Binary Access Write As #fln
            Put #fln, , b()
            Close #fln
            picOut.Print "} saved"

           
        End If

    Next x
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rsp05Author Commented:
robberbaron:  Definately enough to go on.  Appreciate the logic which I am using.  Found some alternate code to accomplish this, but you definately gave me 99% of what I needed - Thanks so much!  I'll post it here for future users:

Private Declare Function URLDownloadToFile Lib "urlmon" _
   Alias "URLDownloadToFileA" _
  (ByVal pCaller As Long, _
   ByVal szURL As String, _
   ByVal szFileName As String, _
   ByVal dwReserved As Long, _
   ByVal lpfnCB As Long) As Long
   
   
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000


Private Sub Form_Load()

   Command1.Caption = "Download File"
   
End Sub

   
Private Sub Command1_Click()

   Dim sSourceUrl As String
   Dim sLocalFile As String
   Dim hfile As Long
   
   sSourceUrl = "http://www.myurl/client1.lic"
   sLocalFile = "c:\localtemp.lic"
   
 
   If DownloadFile(sSourceUrl, sLocalFile) Then
   
      hfile = FreeFile
      Open sLocalFile For Input As #hfile
         msg = Input$(LOF(hfile), hfile)
         MsgBox (msg)
      Close #hfile
     
   End If

End Sub


Public Function DownloadFile(sSourceUrl As String, _
                             sLocalFile As String) As Boolean
 
  'Download the file. BINDF_GETNEWESTVERSION forces
  'the API to download from the specified source.
  'Passing 0& as dwReserved causes the locally-cached
  'copy to be downloaded, if available. If the API
  'returns ERROR_SUCCESS (0), DownloadFile returns True.
   DownloadFile = URLDownloadToFile(0&, _
                                    sSourceUrl, _
                                    sLocalFile, _
                                    BINDF_GETNEWESTVERSION, _
                                    0&) = ERROR_SUCCESS
   
End Function
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.