Set_PC_State ' // By Elektro H@cker
' USAGE:
'
' Set_PC_State(RESET)
' Set_PC_State(SUSPEND, 30, "I'm suspending your system.")
' Set_PC_State(LOG_OFF)
' Set_PC_State(HIBERN)
' Set_PC_State(ABORT)
#Region " Set PC State "
Const RESET As String = " -R "
Const SUSPEND As String = " -S "
Const LOG_OFF As String = " -L "
Const HIBERN As String = " -H "
Const ABORT As String = " -A "
Private Function Set_PC_State(ByVal PowerState_Action As String, Optional ByVal TimeOut As Integer = 1, Optional ByVal COMMENT As String = "")
Dim Shutdown_Command As New ProcessStartInfo
Shutdown_Command.FileName = "Shutdown.exe"
Try
If PowerState_Action = ABORT Or PowerState_Action = HIBERN Or PowerState_Action = LOG_OFF Then
Shutdown_Command.Arguments = PowerState_Action ' Windows don't allow TimeOut or Comment options for HIBERN, LOG_OFF or ABORT actions.
ElseIf PowerState_Action = RESET Or PowerState_Action = SUSPEND Then
If Not COMMENT = "" Then
If COMMENT.Length > 512 Then COMMENT = COMMENT.Substring(0, 512) ' Only 512 chars are allowed for comment
Shutdown_Command.Arguments = PowerState_Action & " -T " & TimeOut & " /C " & COMMENT
Else
Shutdown_Command.Arguments = PowerState_Action & " -T " & TimeOut
End If
Shutdown_Command.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(Shutdown_Command)
Return True
End If
Catch ex As Exception
Return ex.Message
End Try
Return Nothing ' Invalid argument
End Function
#End Region
Día local:Dim Today as string = My.Computer.Clock.LocalTime.DayOfWeek ' In English language
Dim Today as string = System.Globalization.DateTimeFormatInfo.CurrentInfo.GetDayName(Date.Today.DayOfWeek) ' In system language
String is URL? ' USAGE:
'
' If String_Is_URL("http://google.com") Then MsgBox("Valid url!") Else MsgBox("Invalid url!")
#Region " String Is URL Function "
Private Function String_Is_URL(ByVal STR As String)
Dim URL_Pattern As String = "^(http|https):/{2}[a-zA-Z./&\d_-]+"
Dim URL_RegEx As New System.Text.RegularExpressions.Regex(URL_Pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase Or System.Text.RegularExpressions.RegexOptions.ExplicitCapture)
If URL_RegEx.IsMatch(STR) Then Return True Else Return False
End Function
#End Region
G-Mail Sender (Envía emails) ' USAGE:
'
' GMail_Sender("Your_Email@Gmail.com", "Your_Password", "Email Subject", "Message Body", "Destiny@Email.com")
#Region " GMail Sender function "
Private Function GMail_Sender(ByVal Gmail_Username As String, ByVal Gmail_Password As String, ByVal Email_Subject As String, ByVal Email_Body As String, ByVal Email_Destiny As String)
Try
Dim MailSetup As New System.Net.Mail.MailMessage
MailSetup.Subject = Email_Subject
MailSetup.To.Add(Email_Destiny)
MailSetup.From = New System.Net.Mail.MailAddress(Gmail_Username)
MailSetup.Body = Email_Body
Dim SMTP As New System.Net.Mail.SmtpClient("smtp.gmail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New Net.NetworkCredential(Gmail_Username, Gmail_Password)
SMTP.Send(MailSetup)
Return True ' Email is sended OK
Catch ex As Exception
Return ex.Message ' Email can't be sended
End Try
End Function
#End Region