Friday, October 2, 2009

How to register any third party control in windows application if registration key comes from third party website via URL using ASP.NET

In General you can use WebBrowser windows control to get registration key from the third party web site and use it into your windows application like this

Call first your url which will machineid as your key like this:
WebBrowser1.Navigate("https://www.my.com/machineid.html")

Then in WebBrowser1_Navigated event handler:

Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated

Dim mywebclient As New WebBrowser

Dim str As String = WebBrowser1.DocumentText
Dim machineid As String
If counter = 2 Then
      machineid = Mid(WebBrowser1.Url.Query, InStr(WebBrowser1.Url.Query, "arch=") + 5, InStr(WebBrowser1.Url.Query, "&days") - (InStr(WebBrowser1.Url.Query, "arch=") + 5))

      WebBrowser1.Navigate("https://www.cartesianinc.com/Prepaid/Ops/GetLicense.cgi?accountID=username&accountPW=yourpassword&machineID=" & machineid.ToString)

End If
If counter = 3 Then
Dim regkey As String = WebBrowser1.Document.Body.InnerText
         regkey = regkey.Split(">")(1).Split("<")(0)

      WebBrowser1.DocumentText = "<html>" & "<header>" & "/<header>" & "<body>" & "<embed type=""image/cpi"" width= ""100"" height=""100""" & " regkey=""" & regkey & """>" & "</body>" & "</html>"

End Sub

That’s all!

No comments:

Post a Comment