Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace MMOLoader
- {
- public partial class EQVersion : Form
- {
- public EQVersion()
- {
- InitializeComponent();
- }
- private void closeButton_Click(object sender, EventArgs e)
- {
- Hide();
- }
- private void exeLocationButton_Click(object sender, EventArgs e)
- {
- SelectFile();
- }
- private void SelectFile()
- {
- this.Enabled = false;
- exeOpenFileDialog.InitialDirectory = exeLocationTextBox.Text;
- DialogResult drResult = exeOpenFileDialog.ShowDialog();
- if (drResult != DialogResult.OK)
- {
- this.Enabled = true;
- return;
- }
- exeLocationTextBox.Text = exeOpenFileDialog.FileName;
- ReadAndDisplayVersion();
- this.Enabled = true;
- }
- private void ReadAndDisplayVersion()
- {
- try
- {
- FileStream fs = File.OpenRead(exeOpenFileDialog.FileName);
- byte[] buffer = new byte[fs.Length];
- int bytesRead = fs.Read(buffer, 0, buffer.Length);
- fs.Close();
- if (bytesRead > 0)
- {
- string tmpBuffer = ASCIIEncoding.ASCII.GetString(buffer);
- int startLoc = tmpBuffer.IndexOf("Client Version: %s %s") + 48;
- versionTextBox.Text = tmpBuffer.Substring(startLoc);
- startLoc += versionTextBox.TextLength + 1;
- versionTextBox.Text += " " + tmpBuffer.Substring(startLoc);
- if (!(versionTextBox.Text.Contains("20")))
- {
- versionTextBox.Text = "";
- startLoc = tmpBuffer.IndexOf("Client Version: %s %s") - 22;
- string verDate = " ", verTime = " ";
- for (int z = startLoc; z >= 0 && z > startLoc - 100; z--)
- {
- if (tmpBuffer[z] == 0)
- {
- verTime = tmpBuffer.Substring(z + 1);
- if (verTime.Length == 0)
- verTime = "Unknown";
- startLoc = tmpBuffer.IndexOf("Client Version: %s %s") - 2;
- for (int y = startLoc; y >= 0 && y > startLoc - 100; y--)
- {
- if (tmpBuffer[y] == 0)
- {
- verDate = tmpBuffer.Substring(y + 1);
- if (verDate.Length == 0)
- verDate = "Unknown";
- versionTextBox.Text = verDate;
- versionTextBox.Text += " " + verTime;
- break;
- }
- }
- break;
- }
- }
- if (versionTextBox.TextLength == 0)
- versionTextBox.Text = "Unknown";
- }
- }
- else
- {
- versionTextBox.Text = "Unknown";
- }
- MainForm.EQType eqType = MainForm.GetEQType(exeOpenFileDialog.FileName);
- if (eqType == MainForm.EQType.BETA_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Beta Server";
- }
- else if (eqType == MainForm.EQType.LIVE_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Live Servers";
- }
- else if (eqType == MainForm.EQType.TEST_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Test Server";
- }
- else if (eqType == MainForm.EQType.EMU_MAC_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Mac (Macintosh/Al'Kabor) EMU";
- }
- else if (eqType == MainForm.EQType.EMU_ROF2_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Rain of Fear 2 (ROF2) EMU";
- }
- else if (eqType == MainForm.EQType.EMU_ROF_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Rain of Fear (ROF) EMU";
- }
- else if (eqType == MainForm.EQType.EMU_HOT_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: House of Thule (HOT) EMU";
- }
- else if (eqType == MainForm.EQType.EMU_UF_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Underfoot (UF) EMU";
- }
- else if (eqType == MainForm.EQType.EMU_SOD_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Seeds of Destruction (SOD) EMU";
- }
- else if (eqType == MainForm.EQType.EMU_SOF_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Secrets of Faydwer (SOF) EMU";
- }
- else if (eqType == MainForm.EQType.EMU_TIT_TYPE)
- {
- versionLabel.Text = "Version of EverQuest: Titanium (TIT) EMU";
- }
- else
- {
- versionLabel.Text = "Version of EverQuest: Unknown Client Type";
- }
- }
- catch (Exception ex)
- {
- versionTextBox.Text = ex.Message;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment