system.Diagnostics.Process.Start("exe文件")
mspaint (画板)
WINword
devenv
------ ----上面的是 一些 命令 上下 无关系
HKEY_LOCAL_MACHINE\SIFTWARE\Microsoft\Windows\CurrentVersion\Run
---命名空间
using Microsoft.Win32;
---开机启动程序
private void button3_Click(object sender, EventArgs e)
{
string strName = Application.ExecutablePath;
if (!File.Exists(strName))
{
return;
}
string newstr = strName.Substring(strName.LastIndexOf("\\") + 1);
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(newstr, strName);
MessageBox.Show("OK");
}
本文介绍如何使用C#实现程序随Windows系统启动自动运行,并展示了如何启动指定的exe文件。文中提供了具体的代码示例,包括注册表操作及进程启动的方法。
1439

被折叠的 条评论
为什么被折叠?



