从前用native API实现过程序开机自动运行,前几天刚好要用到,就用
c#重写了,基本原理都是一样的。
RegistryKey KeyCon=Registry.LocalMachine.OpenSubKey(
"Software//Microsoft//Windows//CurrentVersion//Run",true);
string MyKey= "Terminal";
if((string)KeyCon.GetValue(MyKey,"no") == "no")//指定的键不存在
{
string Path = Application.StartupPath+@"/Terminal.exe";
KeyCon.SetValue(MyKey,Path); //设置注册表中的启动键
}
MainForm mw = new MainForm();
顺便记录下用c#实现全屏(不带任务栏)的简单方法。
this.FormBorderStyle = FormBorderStyle.None; //设置窗口边框
this.WindowState = FormWindowState.Maximized; //设置程序最大化
注:当然也可以在窗口属性中设置这两个属性值。