private void Form_Setting_Load(object sender, EventArgs e) { textBox_SteamPath.Text = _form1.GetSteamPath(); textBox_CSGOPath.Text = _form1.GetCSGOPath(); try { System.IO.StreamReader st; st = new System.IO.StreamReader(textBox_CSGOPath.Text + @"\csgo\cfg\bind.cfg", System.Text.Encoding.UTF8); //UTF-8通用编码 textBox_KeyCmd.Text = st.ReadToEnd(); st.Close(); StringBuilder rew = new StringBuilder(25); WIN32API.GetPrivateProfileString("Key", "bind", null, rew, 25, Application.StartupPath + "\\Config.ini"); if (rew.ToString() == "true") { checkBox_BindKey.Checked = true; } else { checkBox_BindKey.Checked = false; } } catch { } }
//获取CSGO目录 private void InitCSGOPath() { try { StringBuilder Stream = new StringBuilder(1024); WIN32API.GetPrivateProfileString("Steam", "CSGOPath", null, Stream, 1024, Application.StartupPath + "\\Config.ini"); if (File.Exists(Stream.ToString() + @"\csgo.exe")) { GCSGOPath = Stream.ToString(); return; } WIN32API._GetCSGOPath(Stream, 1024); GCSGOPath = Stream.ToString(); if (File.Exists(GCSGOPath.ToString() + @"\csgo.exe")) { label_DebugOutPut.Text = "获取CSGO目录失败!!"; return; } WIN32API.WritePrivateProfileString("Steam", "CSGOPath", GCSGOPath, Application.StartupPath + "\\Config.ini"); } catch (Exception e) { label_DebugOutPut.Text = e.Message.ToString(); } }
//获取Steam目录 private void InitSteamPath() { try { StringBuilder SteamPath = new StringBuilder(1024); WIN32API.GetPrivateProfileString("Steam", "Path", null, SteamPath, 1024, Application.StartupPath + "\\Config.ini"); if (SteamPath.Length > 5) { GSteamPath = SteamPath.ToString(); return; } string registData; RegistryKey hkml = Registry.LocalMachine; RegistryKey software = hkml.OpenSubKey("SOFTWARE", false); RegistryKey aimdir = software.OpenSubKey("Classes\\steam\\Shell\\Open\\Command", false); registData = aimdir.GetValue(null).ToString(); string[] sArray = Regex.Split(registData, "\"", RegexOptions.IgnoreCase); GSteamPath = sArray[1].ToString(); WIN32API.WritePrivateProfileString("Steam", "Path", GSteamPath, Application.StartupPath + "\\Config.ini"); } catch (Exception e) { label_DebugOutPut.Text = e.Message.ToString(); } }
//启动游戏 private void LauncherGame(string IPO) { if (WIN32API.IsProcessExist("csgo")) { Process.Start("steam://connect/" + IPO, null); _form1.SetDebugString(string.Format("小X加入[{0}]服务器队列啦,[Master]游戏愉快(~o ̄▽ ̄)~o", IPO)); } else { string r; if (checkBox_CN.Checked) { StringBuilder rew = new StringBuilder(25); WIN32API.GetPrivateProfileString("Key", "bind", null, rew, 25, Application.StartupPath + "\\Config.ini"); if (rew.ToString() == "true") { r = string.Format("-applaunch 730 -perfectworld -novid +exec bind +connect {0}", IPO); } else { r = string.Format("-applaunch 730 -perfectworld -novid +connect {0}", IPO); } } else { StringBuilder rew = new StringBuilder(25); WIN32API.GetPrivateProfileString("Key", "bind", null, rew, 25, Application.StartupPath + "\\Config.ini"); if (rew.ToString() == "true") { r = string.Format("-applaunch 730 -worldwide -novid +exec bind +connect {0}", IPO); } else { r = string.Format("-applaunch 730 -worldwide -novid +connect {0}", IPO); } } Process.Start(_form1.GetSteamPath(), r); Sleep(3000); _form1.SetDebugString(string.Format("小X终于挤进[{0}]服务器队列啦,[Master]游戏愉快(~o ̄▽ ̄)~o", IPO)); } label_ServerTick.Text = "服务器队列中"; }
private void Form_MainPage_Load(object sender, EventArgs e) { StringBuilder CnCheck = new StringBuilder(70); WIN32API.GetPrivateProfileString("Steam", "IsChina", null, CnCheck, 70, Application.StartupPath + "\\Config.ini"); if (string.Compare(CnCheck.ToString(), "False") == 0) { checkBox_CN.Checked = false; } else { checkBox_CN.Checked = true; } //初始化服务器列表 listView_Server.Columns.Add("服务器名"); listView_Server.Columns[0].Width = 300; listView_Server.Columns.Add("地图名"); listView_Server.Columns[1].Width = 150; listView_Server.Columns.Add("人数"); listView_Server.Columns.Add("IP:端口"); listView_Server.Columns[3].Width = 100; listView_Server.Columns.Add("地区"); listView_Server.Columns[4].Width = 80; WIN32API.GetPrivateProfileString("Config", "ServerMode", null, CnCheck, 70, Application.StartupPath + "\\Config.ini"); if (string.Compare(CnCheck.ToString(), "") == 1) { ServerMode = CnCheck.ToString(); } else { ServerMode = "all"; } InitServerListInfo(ServerMode); //服务器列表刷新定时器; time_RefreshServer.Enabled = true; time_RefreshServer.Interval = 15 * 1000;//15Secound; time_RefreshServer.Tick += new EventHandler(ServerRefreshEvent); time_RefreshServer.Start(); InitSteamPath(); RefreshMyInfo(); }