namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string app_name= "WindowsFormsApplication1";
string path = Application.ExecutablePath;
RegistryKey rk = Registry.LocalMachine;
RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
if (rk2.GetValue(app_name) != null)
{
rk2.DeleteValue(app_name, false);
}
rk2.SetValue(app_name, path);
rk2.Close();
rk.Close();
}
catch(Exception ex)
{
MessageBox.Show("fail\n");
}
}
}
}
開機自動執行
https://sites.google.com/site/cshapeexamples/home/reg-read-write
C# windows form 開發,讓應用程式開機時自動啟動
http://www.sukitech.com/922/c-windows-form-%E9%96%8B%E7%99%BC%EF%BC%8C%E8%AE%93%E6%87%89%E7%94%A8%E7%A8%8B%E5%BC%8F%E9%96%8B%E6%A9%9F%E6%99%82%E8%87%AA%E5%8B%95%E5%95%9F%E5%8B%95%E3%80%82/
C#開機直接啟動應用程式
http://blog.xuite.net/merci0212/wretch/141175698-C%23+%E9%96%8B%E6%A9%9F%E7%9B%B4%E6%8E%A5%E5%95%9F%E5%8B%95%E6%87%89%E7%94%A8%E7%A8%8B%E5%BC%8F
windows 8-設定開機要立刻執行
http://isvincent.pixnet.net/blog/post/38425585-windows-8-%E8%A8%AD%E5%AE%9A%E9%96%8B%E6%A9%9F%E8%A6%81%E7%AB%8B%E5%8D%B3%E5%9F%B7%E8%A1%8C%E7%9A%84%E7%A8%8B%E5%BC%8F
沒有留言:
張貼留言