05-07-2011, 08:49 AM
(This post was last modified: 05-07-2011, 08:52 AM by Resistance.)
Hello there, here are little code snippets I compiled up for you guys. They are extremely helpful if you are new to VB and want to know how VB code works, functions and looks like. Enjoy.
Delete a File:
Kill a Process:
Delete a Registry Key:
Rename a File:
Create a Registry Key:
Text to Speach:
Getting The Operating system Name:
Gets OS Version & Build Number:
Gets Available Physical Memory:
Gets Total Physical Memory:
Gets the clipboard text:
CD-ROM Prank (opens and closes):
RC4 Text Encryption
Auto Typer
Listbox Auto Scroll
Send Email
Once Again, Enjoy.
Code from: www.pro-coders.com
Delete a File:
Code:
Dim FileToDelete As String
FileToDelete = "C:\File.exe"
If System.IO.File.Exists(FileToDelete) = True Then
System.IO.File.Delete(FileToDelete)
Kill a Process:
Code:
Dim RunningProcess As System.Diagnostics.Process = Process.GetProcessesByName("taskmgr.exe")(0)
RunningProcess.Kill()
Delete a Registry Key:
Code:
My.Computer.Registry.LocalMachine.DeleteSubKey("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SafeBoot")
Rename a File:
Code:
My.Computer.FileSystem.RenameFile ("C:\Program Files\Mozilla Firefox\firefox.exe", "Anything.exe")
Create a Registry Key:
Code:
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
regKey.CreateSubKey("MyApp")
regKey.Close()
Text to Speach:
Code:
Dim sapi
sapi = CreateObject("sapi.spvoice")
sapi.Speak(Textbox1.text)
Getting The Operating system Name:
Code:
Textbox1.text = My.Computer.Info.OSFullName
Gets OS Version & Build Number:
Code:
Textbox2.text = My.Computer.Info.OSVersion
Gets Available Physical Memory:
Code:
Textbox4.text = My.Computer.Info.AvailablePhysicalMemory
Gets Total Physical Memory:
Code:
Textbox3.text = My.Computer.Info.TotalPhysicalMemory
Gets the clipboard text:
Code:
Textbox5.text = My.Computer.Clipboard.GetText
CD-ROM Prank (opens and closes):
Code:
Do
Dim oWMP = CreateObject("WMPlayer.OCX.7")
Dim colCDROMs = oWMP.cdromCollection
If colCDROMs.Count = 1 Then
For i = 0 To colCDROMs.Count - 1
colCDROMs.Item(i).Eject()
Next ' cdrom
End If
Loop
RC4 Text Encryption
Code:
Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
Dim i As Integer = 0
Dim j As Integer = 0
Dim cipher As New StringBuilder
Dim returnCipher As String = String.Empty
Dim sbox As Integer() = New Integer(256) {}
Dim key As Integer() = New Integer(256) {}
Dim intLength As Integer = password.Length
Dim a As Integer = 0
While a <= 255
Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0))
key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp)
sbox(a) = a
System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
End While
Dim x As Integer = 0
Dim b As Integer = 0
While b <= 255
x = (x + sbox(b) + key(b)) Mod 256
Dim tempSwap As Integer = sbox(b)
sbox(b) = sbox(x)
sbox(x) = tempSwap
System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1)
End While
a = 1
While a <= message.Length
Dim itmp As Integer = 0
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
itmp = sbox(i)
sbox(i) = sbox(j)
sbox(j) = itmp
Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256)
Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0)
itmp = Asc(ctmp)
Dim cipherby As Integer = itmp Xor k
cipher.Append(Chr(cipherby))
System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
End While
returnCipher = cipher.ToString
cipher.Length = 0
Return returnCipher
End Function
Auto Typer
Code:
Public Class Form1
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If CheckBox1.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox1.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox2.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox2.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox3.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox3.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox4.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox4.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
If CheckBox5.Checked = True Then
On Error Resume Next
SendKeys.Send(TextBox5.Text)
On Error Resume Next
SendKeys.Send("{Enter}")
End If
Timer1.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Stop()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
Listbox Auto Scroll
Code:
ListBox1.TopIndex = ListBox1.Items.Count - 1
Send Email
Code:
Dim SetUPMAIL As New MailMessage()
Try
SetUPMAIL.From = New MailAddress("YOURGOOGLEEMAIL@googlemail.com")
SetUPMAIL.To.Add("YOUREMAIL@ANYHOST.COM")
SetUPMAIL.Subject = "Subject"
SetUPMAIL.Body = "Body"
Dim SMTP As New SmtpClient("smtp.googlemail.com" or "smtp.gmail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("YOURGOOGLEEMAIL@googlemail.com", "GOOGLEMAILPASSWORD")
SMTP.Send(SetUPMAIL)
Once Again, Enjoy.
Code from: www.pro-coders.com