-
- private void button1_Click(object sender, System.EventArgs e)
- {
- RegistryKey hklm = Registry.LocalMachine;
-
-
-
-
-
- RegistryKey run = hklm.CreateSubKey(@"Software/Microsoft/Windows/CurrentVersion/Run");
- try
- {
-
-
-
-
-
-
-
- run.SetValue("MyNote.exe", @"" + Application.ExecutablePath);
-
-
-
- MessageBox.Show("添加注册表启动项成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- hklm.Close();
- }
- catch (Exception my)
- {
- MessageBox.Show(my.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
-
- }
-
-
- private void button2_Click(object sender, System.EventArgs e)
- {
- RegistryKey hklm = Registry.LocalMachine;
- RegistryKey run = hklm.CreateSubKey(@"Software/Microsoft/Windows/CurrentVersion/Run");
- try
- {
-
- run.DeleteValue("MyNote.exe");
- MessageBox.Show("移除注册表启动项成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- hklm.Close();
- }
- catch (Exception my)
- {
- MessageBox.Show(my.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
posted @
2010-10-15 15:17
deepwishly
阅读(
397)
评论()
编辑
收藏
举报