现在的位置: 首页 > 综合 > 正文

VS2010 + .net4.0 一个小程序锁屏软件 支持开机自启动 源码 免积分下载

2018年07月07日 ⁄ 综合 ⁄ 共 1031字 ⁄ 字号 评论关闭


通过获取命令行参数来判断他是不是开机启动 还是双机启动

 String commandLineString = System.Environment.CommandLine;
 String[] args = System.Environment.GetCommandLineArgs();

添加开机启动

try
            {
                string exeDir = Application.ExecutablePath + " " + tb_pass.Text;
                RegistryKey rk = Registry.LocalMachine;
                RegistryKey softWare = rk.OpenSubKey("SOFTWARE");
                RegistryKey microsoft = softWare.OpenSubKey("Microsoft");
                RegistryKey windows = microsoft.OpenSubKey("Windows");
                RegistryKey current = windows.OpenSubKey("CurrentVersion");
                RegistryKey run = current.OpenSubKey(@"Run", true);
                run.SetValue("ScreenLock", exeDir);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

取消开机启动

try
            {
                RegistryKey rk = Registry.LocalMachine;
                RegistryKey softWare = rk.OpenSubKey("Software");
                RegistryKey microsoft = softWare.OpenSubKey("Microsoft");
                RegistryKey windows = microsoft.OpenSubKey("Windows");
                RegistryKey current = windows.OpenSubKey("CurrentVersion");
                RegistryKey run = current.OpenSubKey(@"Run", true);
                run.DeleteValue("ScreenLock");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

通过全局钩子来屏蔽一些按键 

源代码下载地址:http://download.csdn.net/detail/xzh1995/6534905


抱歉!评论已关闭.