好友
阅读权限 10
听众
最后登录 1970-1-1
本帖最后由 爱你么么哒呀 于 2018-10-31 13:28 编辑
@冰炎梦幻 根据他提供的源码简单优化了代码,主要是学习一下!.
成品地址:https://pan.baidu.com/s/1DOSIoJP5iq6ZbcsuC_6LGQ 提取码: f73n
ps:界面更丑了,,,
源码:
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace 测试
{
public partial class Rng : Form
{
public Rng()
{
InitializeComponent();
}
private void Rng_Load(object sender, EventArgs e)
{
this.Text = "Steam多账户登陆器";
}
private void button1_Click(object sender, EventArgs e)
{
string user = comboBox1.Text;
WTRegedit("AutoLoginUser", user);
killProcess();
string path0 = GetRegistData(registData);
string path1 = @path0; //打开Steam
Process.Start(path1);
}
private void WTRegedit(string AutoLoginUser, string username)
{
RegistryKey hklm = Registry.CurrentUser;
RegistryKey software = hklm.OpenSubKey("SOFTWARE", true);
RegistryKey aimdir = software.OpenSubKey("Valve", true);
RegistryKey aimdir2 = aimdir.OpenSubKey("Steam", true);
aimdir2.SetValue(AutoLoginUser, username);
}
private string GetRegistData(string SteamExe)
{
string registData;
RegistryKey hklm = Registry.CurrentUser;
RegistryKey software = hklm.OpenSubKey("SOFTWARE", true);
RegistryKey aimdir = software.OpenSubKey("Valve", true);
RegistryKey aimdir2 = aimdir.OpenSubKey("Steam", true);
registData = aimdir2.GetValue("SteamExe").ToString();
return registData;
}
public string registData { get; set; }
private void killProcess()
{
Process[] ps = Process.GetProcesses();
foreach (Process item in ps)
{
if (item.ProcessName == "Steam")
{
item.Kill();
}
}
}
private void comboBox1_DropDown(object sender, EventArgs e)
{
try
{
comboBox1.Items.Clear();
FileInfo fi = new FileInfo(@"C:\\Steamaccount.txt");
StreamReader sr = fi.OpenText();
string strLine = string.Empty;
while ((strLine = sr.ReadLine()) != null)
{
comboBox1.Items.Add(strLine);
}
sr.Dispose();
string user = comboBox1.Text;
return;
}
catch (Exception)
{
MessageBox.Show("没有找到C:\\\\Steamaccount.txt文件");
}
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("1、请在C盘创建一个Steamaccount.txt,具体路径(C:\\\\Steamaccount.tx)\n\r2、把ID写在Steamaccount.txt里,一行一个。\n\rPS:各个账号都在电脑上点了记住密码登录过。");
}
}
}
免费评分
查看全部评分
发帖前要善用【论坛搜索 】 功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。