· 5 years ago · Mar 31, 2020, 10:16 AM
1Imports System.Diagnostics
2Imports System.Net
3Imports System.IO
4Imports System.Runtime.CompilerServices
5Imports Microsoft.VisualBasic.Devices
6Imports System.Net.Mail
7
8Public Class Utils
9 Public Shared Sub RunAppWithArg(fileName As String, fileNameArg As String)
10 Dim startInfo As New ProcessStartInfo
11 startInfo.FileName = fileName
12 startInfo.Arguments = fileNameArg
13 Process.Start(startInfo)
14 End Sub
15
16 Public Shared Sub DownloadFile(fileURL As String, fileDirectory As String)
17 Using client As New WebClient()
18 client.DownloadFile(fileURL, fileDirectory)
19 End Using
20 End Sub
21
22 Private Shared RandomKey As New Random()
23 Public Shared Function GenerateSecretKey() As String
24
25 Randomize()
26
27 Return RandomKey.Next(1000000, 100000000).ToString & "ABC"
28 End Function
29
30
31 Public Shared Function SendEmail(emailFake As String, passwordFake As String, email As String, yourMessage As String) As Boolean
32 Try
33 Dim SmtpServer As New SmtpClient()
34 Dim mail As New MailMessage()
35 SmtpServer.Credentials = New _
36 Net.NetworkCredential(emailFake, passwordFake)
37 SmtpServer.Port = 587
38 SmtpServer.Host = "smtp.gmail.com"
39 SmtpServer.EnableSsl = True
40 mail = New MailMessage()
41 mail.From = New MailAddress(emailFake)
42 mail.To.Add(email)
43 mail.Subject = "SecretKey"
44 mail.Body = yourMessage
45 SmtpServer.Send(mail)
46 Console.WriteLine("Il faut demander à Sufoad la clef !")
47 Return True
48 Catch ex As Exception
49 Console.WriteLine("Oups il y a une petite erreur ! contact Sufoad")
50 Return False
51 End Try
52 End Function
53
54 Private Function CpuId() As String
55 Dim computer As String = "."
56 Dim wmi As Object = GetObject("winmgmts:" &
57 "{impersonationLevel=impersonate}!\\" &
58 computer & "\root\cimv2")
59 Dim processors As Object = wmi.ExecQuery("Select * from " &
60 "Win32_Processor")
61
62 Dim cpu_ids As String = ""
63 For Each cpu As Object In processors
64 cpu_ids = cpu_ids & ", " & cpu.ProcessorId
65 Next cpu
66 If cpu_ids.Length > 0 Then cpu_ids =
67 cpu_ids.Substring(2)
68
69 Return cpu_ids
70 End Function
71End Class