1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| Imports System.IO
Imports System.Management
Public Class Form1
Dim cpuInfo As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = System.Environment.MachineName
TextBox2.Text = My.Computer.Info.OSFullName
txtHWID.Text = GetHWID()
Me.AcceptButton = btnConnect
End Sub
Function GetHWID()
Dim mc As New ManagementClass("win32_processor")
Dim moc As ManagementObjectCollection = mc.GetInstances
For Each mo As ManagementObject In moc
If cpuInfo = "" Then
cpuInfo = mo.Properties("processorID").Value.ToString
Exit For
End If
Next
Return cpuInfo
End Function
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Dim Request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("lien URL direct du fichier en .txt")
Dim Response As System.Net.HttpWebResponse = Request.GetResponse()
Dim SR As System.IO.StreamReader = New System.IO.StreamReader(Response.GetResponseStream)
Dim HWIDAdded As String = SR.ReadToEnd
Dim ThisHWID As String = GetHWID()
If HWIDAdded.Contains(ThisHWID) Then
Form2.show()
MsgBox("Clé de license validée")
Me.Hide()
Else
MsgBox("Cle de license invalide")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
txtHWID.Text = (GetHWID())
End Sub
End Class |
Partager