Loading

自启动注册

   public void RunWhenStart(bool Started, string name, string path)
        {
            RegistryKey HKLM = Registry.LocalMachine;
            RegistryKey Run = HKLM.CreateSubKey(@"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\");
            if (Started == true)
            {
                try
                {
                    Run.SetValue(name, path);
                    HKLM.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("注册表修改错误(开机自启未实现)");
                }
            }
            else
            {
                try
                {
                    if (Run.GetValue(name) != null)
                    {
                        Run.DeleteValue(name);
                        HKLM.Close();
                    }
                    else
                        return;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    // 
                }
            }
posted @ 2009-10-13 16:11  today4king  阅读(154)  评论(0编辑  收藏  举报