Advertisement
mferrill

Launcher Code

Aug 24th, 2012
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Net
  2. Imports System.Net.Sockets
  3. Public Class Form1
  4.     Dim Apache As New TcpClient
  5.     Dim World As New TcpClient
  6.  
  7.     Private Sub PictureBox1_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
  8.         PictureBox1.Image = My.Resources.PlayClick
  9.         If File.Exists(My.Computer.FileSystem.CurrentDirectory & "/Wow.exe") Then
  10.             REM This tells the launcher to check the current directory for Wow.exe
  11.             Shell(My.Computer.FileSystem.CurrentDirectory & "/Wow.exe")
  12.             REM If Wow.exe is found this tells the launcher to start Wow.exe
  13.             Me.Close()
  14.             REM This tells the launcher to close after it start Wow.exe
  15.         Else
  16.             MsgBox("Could not start Wow.exe", MsgBoxStyle.Critical, "Application Not Found")
  17.             REM If Wow.exe is not found this tells the launcher to show an error message
  18.         End If
  19.     End Sub
  20.     Private Sub PictureBox1_MouseEnter(sender As Object, e As System.EventArgs) Handles PictureBox1.MouseEnter
  21.         PictureBox1.Image = My.Resources.PlayEnter
  22.         REM This tells the PictureBox image to change to PlayEnter.png
  23.  
  24.     End Sub
  25.  
  26.     Private Sub PictureBox1_MouseLeave(sender As Object, e As System.EventArgs) Handles PictureBox1.MouseLeave
  27.         PictureBox1.Image = My.Resources.PlayLeave
  28.         REM This tells the PictureBox image to change to PlayLeave.png
  29.     End Sub
  30.  
  31.     Private Sub PictureBox2_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseClick
  32.         PictureBox2.Image = My.Resources.SupportClick
  33.         REM This tells the PictureBox2 image to change to SupportClick.png
  34.         Process.Start("http://YOUR WEBSITE HERE")
  35.         REM This tells the launcher to open your servers website
  36.     End Sub
  37.  
  38.     Private Sub PictureBox2_MouseEnter(sender As Object, e As System.EventArgs) Handles PictureBox2.MouseEnter
  39.         PictureBox2.Image = My.Resources.SupportEnter
  40.         REM This tells the PictureBox2 image to change to SupportEnter.png
  41.     End Sub
  42.  
  43.     Private Sub PictureBox2_MouseLeave(sender As Object, e As System.EventArgs) Handles PictureBox2.MouseLeave
  44.         PictureBox2.Image = My.Resources.SupportLeave
  45.         REM This tells the PictureBox2 image to change to SupportLeave.png
  46.     End Sub
  47.  
  48.     Private Sub PictureBox3_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox3.MouseClick
  49.         PictureBox3.Image = My.Resources.OptionsClick
  50.         REM This tells the PictureBox3 image to change to OptionsClick.png
  51.         If Directory.Exists(My.Computer.FileSystem.CurrentDirectory & "/Cache") Then
  52.             REM This tells the launcher to check its current directory for a folder named "Cache"
  53.             Dim Cache As String = (My.Computer.FileSystem.CurrentDirectory & "/Cache")
  54.             REM This tells the launcher to turn the directory location of the cache folder into a string.
  55.             Select MsgBox("Do you want to delete the Cache folder?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, "WARNING")
  56.                 REM This tells the launcher to display a message box with a yes and no button
  57.                 Case MsgBoxResult.Yes
  58.                     REM What happens when you press the yes button
  59.                     Directory.Delete(Cache, True)
  60.                     REM Deletes the cache folder
  61.                 Case MsgBoxResult.No
  62.                     REM Tells the launcher to do nothing if the no button is pressed
  63.     End Sub
  64.  
  65.     Private Sub PictureBox3_MouseEnter(sender As Object, e As System.EventArgs) Handles PictureBox3.MouseEnter
  66.         PictureBox3.Image = My.Resources.OptionsEnter
  67.         REM This tells the PictureBox3 image to change to OptionsEnter.png
  68.     End Sub
  69.  
  70.     Private Sub PictureBox3_MouseLeave(sender As Object, e As System.EventArgs) Handles PictureBox3.MouseLeave
  71.         PictureBox3.Image = My.Resources.OptionsLeave
  72.         REM This tells the PictureBox3 image to change to OptionsLeave.png
  73.     End Sub
  74.  
  75.     Private Sub Label1_Click(sender As System.Object, e As System.EventArgs) Handles Label1.Click
  76.  
  77.     End Sub
  78.  
  79.     Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
  80.         Try
  81.             REM Tells the launcher to try to do the following
  82.             Apache.Connect("My External IP address", (80))
  83.             REM Tells the launcher to connect to your servers IP address on port 80
  84.         Catch ex As Exception
  85.             REM Tells the launcher what to do if a connection is not made
  86.             Label1.Visible = True
  87.             REM Tells the launcher to make label1 visible
  88.         End Try
  89.         REM Tells the launcher to stop trying the above
  90.         Try
  91.             REM Tell the launcher to try the following
  92.             World.Connect("My External IP address", (8085))
  93.             REM Tells the launcher to connect to your server IP address on port 8085
  94.         Catch ex As Exception
  95.             REM Tells the launcher what to do if a connection is not made
  96.             Label3.Text = "OFFLINE"
  97.             REM Tells the launcher to set label3's text to "OFFLINE'
  98.            Label3.ForeColor = Color.Red
  99.             REM Tells the launcher to set label3's forecolor to red
  100.        End Try
  101.         REM Tells the launcher to stop trying the above
  102.  
  103.         If Apache.Connected Then
  104.             REM Checks if Apache is connected
  105.             WebBrowser1.Visible = True
  106.             REM Makes the web browser visible if Apache is connected
  107.             WebBrowser1.Navigate("http://www.maleficwow.com/launcher/news.html")
  108.             REM Navigates the web browser to http://www.maleficwow.com/launcher/news.html
  109.             Label1.Hide()
  110.             REM Hides label1 from view
  111.             Apache.Close()
  112.             REM Closes the socket Apache was using *ALWAYS CLOSE YOUR SOCKETS
  113.         End If
  114.         REM Ends the above IF statement
  115.  
  116.         If World.Connected Then
  117.             REM Checks if World is connected
  118.             Label3.Text = "ONLINE"
  119.             REM Changes lebel3's text to "ONLINE" if World is connected
  120.            Label3.ForeColor = Color.Green
  121.             REM Changes label3's fore color to green if World is connected
  122.            World.Close()
  123.             REM Closes the socket World was using *ALWAYS CLOSE YOUR SOCKETS
  124.         End If
  125.         REM Ends the above if statement
  126.     End Sub
  127. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement