关于操作注册表

呃,做这个的思路呢,一切的源头,但是因为我懒。。。

每天开机,要打开工作网站vso,还要打开vs,sql,邮箱。。。。

每天重复,乐此不疲(其实已经很疲了)

所以,忽然想到这些东西能不能在我开机后自动启动呢。。?

最一开始想到了bat,写了一个服务+运行bat文件,发现运行后没有结果。。。

what fuck 。。

于是在这茫茫网络大海,看到了注册表。

于是,讲bat文件里的路径拷贝到了注册表里的Run。

奇迹出现了,妈妈再也不用担心我每天开机启动这些东西了。

假如就像vs。。

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe"

浏览器打开默认网址

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="%APPDATA%\Google\Chrome\User Data" --disk-cache-dir="%LocalAppData%\Google\Chrome\User Data" http://www.baidu.com

可是我很懒,这样岂不是每次换电脑都要找那密密麻麻的注册表。。

于是我写了个程序去操作注册表。。

 var sofName = this.txturl.Text.Trim();
            //创建
            RegistryKey key = Registry.LocalMachine;
            RegistryKey software = key.CreateSubKey(sofName);
            //该项必须已存在
            RegistryKey opensoftware = key.OpenSubKey(sofName, true);

            opensoftware.SetValue(this.txtName.Text.Trim(), this.textBox3.Text.Trim());
            opensoftware.Close();
            key.Close();

            MessageBox.Show("创建成功!");

然后修改注册表值

  var sofName = this.txturl.Text.Trim();
            RegistryKey key = Registry.LocalMachine;
            //该项必须已存在
            RegistryKey opensoftware = key.OpenSubKey(sofName, true);

            opensoftware.SetValue(this.txtName.Text.Trim(), this.textBox3.Text.Trim());
            opensoftware.Close();
            MessageBox.Show("修改成功!");

当然得有删除

 var sofName = this.txturl.Text.Trim();
            RegistryKey delKey = Registry.LocalMachine.OpenSubKey(sofName, true);
            delKey.DeleteValue(this.txtName.Text.Trim());
            delKey.Close();
            MessageBox.Show("删除成功!");

当然必须得有读取。。

    var sofName = this.txturl.Text.Trim();
            string info = "";
            RegistryKey Key;
            Key = Registry.LocalMachine;
            var myreg = Key.OpenSubKey(sofName);
            // myreg = Key.OpenSubKey("software\\test",true);
            info = myreg.GetValue(this.txtName.Text.Trim()).ToString();
            myreg.Close();
            this.textBox3.Text = info;

嗯,我真的好懒,为了防止以后找代码,我还打了包。。

安装文件下载地址:链接: https://pan.baidu.com/s/175lT7A-6suT9aan3GWMaNA 密码: 8z99

源代码地址:链接: https://pan.baidu.com/s/1sWauhgF9qaes9xYdLCnfyQ 密码: zin3

嗯,写这么多,好累。

如果能干掉(绕过)杀毒软件就好了。

杀毒软件还是会拦截的。

唉。。。。。。。。。。。。

如果有大神有这方面的知识,跪求赐教。。

附一张图吧。。

要不然看不懂。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章