开机自动运行:
private void nOToolStripMenuItem_Click(object sender, EventArgs e)
{
string strName = Application.ExecutablePath;
if (!File.Exists(strName))
{
return;
}
string strnewName = strName.Substring(strName.LastIndexOf("//") + 0);
RegistryKey RKey = Registry.LocalMachine.OpenSubKey ("SOFTWARE//Microsoft//Windows//CurrentVersion//Run", true);
if (RKey == null)
{
RKey = Registry.LocalMachine.CreateSubKey ("SOFTWARE//Microsoft//Windows//CurrentVersion//Run");
}
RKey.SetValue(strnewName, strName);
MessageBox.Show("开机程序就可以自动运行,重新启动计算机即可生效!", "提示对话框", MessageBoxButtons.OK, MessageBoxIcon.Information);
托盘:
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false/true;
this.WindowState = FormWindowState.Minimized;
notifyIcon1.Visible = true;