Guest User

Untitled

a guest
Jul 6th, 2013
1,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 7.75 KB | None | 0 0
  1. 'Form Load event:
  2.  
  3.         web_mod = New WebBrowser
  4.         web_mod.Navigate("http://ikillcraft.a0001.net/modpacks.php?pass=test")
  5.         web_mod.Height = 300
  6.         web_mod.Width = 395
  7.         web_mod.Top = 150
  8.         web_mod.Left = 177
  9.         web_mod.Visible = False
  10.         web_mod.ScrollBarsEnabled = False
  11.         'AddHandler web_mod.DocumentCompleted, AddressOf WebBrowser_DocumentCompleted
  12.         Me.Controls.Add(web_mod)
  13.  
  14.         labelestado = New Label
  15.         labelestado.Width = 395
  16.         labelestado.Height = 50
  17.         labelestado.Top = 400
  18.         labelestado.Left = 177
  19.         labelestado.Visible = False
  20.         labelestado.TextAlign = ContentAlignment.MiddleCenter
  21.         Me.Controls.Add(labelestado)
  22.  
  23. 'prueba Function    
  24.  
  25. Private Sub prueba()
  26.  
  27.         Try
  28.  
  29.             labelestado.Visible = True
  30.  
  31.             Windows.Forms.Cursor.Current = Cursors.WaitCursor
  32.  
  33.             labelestado.Text = "Obteniendo y creando nuevas variables"
  34.             Dim getname As String = selectedHtmlElement_NAME
  35.             Dim prueba1 As String = web_mod.Document.GetElementById(getname & "-nombre").GetAttribute("Value")
  36.             Dim prueba2 As String = web_mod.Document.GetElementById(getname & "-dwl").GetAttribute("Value")
  37.             Dim prueba6 As String = web_mod.Document.GetElementById(getname & "-ver").GetAttribute("Value")
  38.             Dim prueba7 As String = web_mod.Document.GetElementById(getname & "-name").GetAttribute("Value")
  39.             Dim prueba8 As String = web_mod.Document.GetElementById(getname & "-desc").GetAttribute("Value")
  40.             Dim prueba9 As String = web_mod.Document.GetElementById(getname & "-vermc").GetAttribute("Value")
  41.             Dim prueba10 As String = web_mod.Document.GetElementById(getname & "-id").GetAttribute("Value")
  42.  
  43.             'MsgBox(prueba1)
  44.             'MsgBox(prueba2)
  45.             'MsgBox(prueba6)
  46.             'MsgBox(prueba7)
  47.             'MsgBox(prueba8)
  48.             'MsgBox(prueba9)
  49.             'MsgBox(prueba10)
  50.  
  51.             labelestado.Text = "Comprando si el archivo Run.bat existe"
  52.             If Not File.Exists(".\Minecraft\PackMods\" & prueba7 & "\run.bat") Then
  53.  
  54.                 labelestado.Text = "Leyendo Ini"
  55.                 Dim value As String = File.ReadAllText(".\Test.ini")
  56.                 labelestado.Text = "Contando similitudes"
  57.                 Dim cuenta As Integer = Find_String_Occurrences(value, "2ç0k")
  58.                 labelestado.Text = "Creando variable"
  59.                 Dim prueba3 As String = ".\Temp\modpack-" & cuenta & ".zip"
  60.  
  61.                 labelestado.Text = "Comprobado si el archivo existe"
  62.                 If File.Exists(prueba3) Then
  63.                     labelestado.Text = "Borrando archivo para evitar conflictos"
  64.                     File.Delete(prueba3)
  65.                 End If
  66.                 labelestado.Text = "descargando Paquete de Mods: " & prueba1
  67.                 My.Computer.Network.DownloadFile(
  68.             prueba2,
  69.             ".\Temp\modpack-" & cuenta & ".zip")
  70.  
  71.                 labelestado.Text = "Extrayendo Paquete de Mods: " & prueba1
  72.                 Extraer.Extraer(prueba3, ".\Minecraft\PackMods\" & prueba7 & "\")
  73.  
  74.                 labelestado.Text = "Definiendo variable del Splash"
  75.                 Dim prueba4 As String = ".\Minecraft\PackMods\" & prueba7 & "\Splash.png"
  76.  
  77.                 labelestado.Text = "Introduciendo nuevos datos en el INI"
  78.                 INI_Manager.Set_Value(".\Test.ini", "Contar" & cuenta, "2ç0k")
  79.                 INI_Manager.Set_Value(".\Test.ini", "FuncId-" & cuenta, prueba10)
  80.                 INI_Manager.Set_Value(".\Test.ini", "FuncNombre-" & cuenta, prueba1)
  81.                 INI_Manager.Set_Value(".\Test.ini", "FuncImg-" & cuenta, prueba4)
  82.  
  83.                 labelestado.Text = "Creando variable"
  84.                 Dim prueba5 As String = ".\Minecraft\PackMods\" & prueba7 & "\run.bat"
  85.  
  86.                 labelestado.Text = "Introduciendo nuevos datos en el INI"
  87.                 INI_Manager.Set_Value(".\Test.ini", "FuncDir-" & cuenta, prueba5)
  88.                 INI_Manager.Set_Value(".\Test.ini", "FuncVer-" & cuenta, prueba6)
  89.                 INI_Manager.Set_Value(".\Test.ini", "FuncName-" & cuenta, prueba7)
  90.                 INI_Manager.Set_Value(".\Test.ini", "FuncDesc-" & cuenta, prueba8)
  91.                 INI_Manager.Set_Value(".\Test.ini", "FuncMcVer-" & cuenta, prueba9)
  92.  
  93.                 labelestado.Text = "Creando variables"
  94.                 Dim sRenglon As String = Nothing
  95.                 Dim strStreamW As Stream = Nothing
  96.                 Dim strStreamWriter As StreamWriter = Nothing
  97.                 Dim ContenidoArchivo As String = Nothing
  98.                 Dim PathArchivo As String
  99.                 Dim ObjItemtot As Integer
  100.                 Dim ObjItemtot2 As Integer
  101.  
  102.                 Try
  103.  
  104.                     PathArchivo = prueba5
  105.                     labelestado.Text = "Comprobando si el archivo existe"
  106.                     If File.Exists(PathArchivo) Then
  107.                         labelestado.Text = "Abriendo el archivo"
  108.                         strStreamW = File.Open(PathArchivo, FileMode.Open)
  109.                     Else
  110.                         labelestado.Text = "Creando archivo"
  111.                         strStreamW = File.Create(PathArchivo)
  112.                     End If
  113.  
  114.                     labelestado.Text = "Definiendo variable"
  115.                     Dim ObjItem As String
  116.                     labelestado.Text = "Obteniendo Memoria RAM disponible"
  117.                     ObjItem = Int(((My.Computer.Info.TotalPhysicalMemory) / 1048576))
  118.  
  119.                     labelestado.Text = "Definiendo tope de Memoria RAM a usar"
  120.                     ObjItemtot = ObjItem / 3
  121.  
  122.                     ObjItemtot2 = ObjItem / 4
  123.  
  124.                     labelestado.Text = "Editando archivo"
  125.                     strStreamWriter = New StreamWriter(strStreamW, System.Text.Encoding.Default)
  126.  
  127.                     labelestado.Text = "Introduciendo líneas de texto dentro del archivo"
  128.                     strStreamWriter.WriteLine("@echo off")
  129.                     strStreamWriter.WriteLine("set APPDATA=" & Application.StartupPath & "\Minecraft\PackMods\" & prueba7)
  130.                     strStreamWriter.WriteLine("java  -Xincgc -Xmx%1m -Xms%2m -cp ""%APPDATA%\.minecraft\bin\minecraft.jar;%APPDATA%\.minecraft\bin\lwjgl.jar;%APPDATA%\.minecraft\bin\lwjgl_util.jar;%APPDATA%\.minecraft\bin\jinput.jar"" -Djava.library.path=""%APPDATA%\.minecraft\bin\natives"" net.minecraft.client.Minecraft %3")
  131.                     strStreamWriter.WriteLine("break")
  132.  
  133.                     labelestado.Text = "Cerrando el editor"
  134.                     strStreamWriter.Close()
  135.  
  136.                 Catch ex As Exception
  137.                     MsgBox("Error al Guardar la ingormacion en el archivo. " & ex.ToString, MsgBoxStyle.Critical, Application.ProductName)
  138.                     strStreamWriter.Close()
  139.                 End Try
  140.  
  141.                 labelestado.Text = "Introduciendo nuevos datos en el INI"
  142.                 INI_Manager.Set_Value(".\Test.ini", "Xmx-" & cuenta, ObjItemtot2)
  143.                 INI_Manager.Set_Value(".\Test.ini", "Xms-" & cuenta, ObjItemtot)
  144.  
  145.                 labelestado.Text = "Borrando archivos temporales"
  146.                 File.Delete(prueba3)
  147.  
  148.                 labelestado.Text = "¡" & prueba1 & " ha sido instalado correctamente!" & vbCrLf & "Muchas gracias por usar IkillLauncher"
  149.                 MsgBox("Debe reiniciar la app para que los cambios surtan efecto." & vbCrLf & "Pulse el botón ""Aceptar"" para continuar.")
  150.                 Application.Restart()
  151.             Else
  152.                 MsgBox("Este ModPack ya lo tienes instalado!")
  153.             End If
  154.  
  155.  
  156.         Catch ex As Exception
  157.             MsgBox(ex.Message & ex.ToString)
  158.         End Try
  159.  
  160.         Windows.Forms.Cursor.Current = Cursors.Default
  161.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment