C#实现将应用程序设置为开机启动的方法
2015-10-13 12:10
627 查看
C#实现将应用程序设置为开机启动的方法
作者:我心依旧
这篇文章主要介绍了C#实现将应用程序设置为开机启动的方法,涉及C#针对注册表的写入技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了C#实现将应用程序设置为开机启动的方法。分享给大家供大家参考。具体如下:
private void WriteRegistry()
{
string strName = Application.ExecutablePath;
if (File.Exists(strName))
{
string strNewName = Path.GetFileName(strName);
RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (reg == null)
{
reg = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
}
else
{
if (reg.GetValue(strNewName) == null)
{
reg.SetValue(strNewName, strName);
}
}
}
}
作者:我心依旧
这篇文章主要介绍了C#实现将应用程序设置为开机启动的方法,涉及C#针对注册表的写入技巧,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了C#实现将应用程序设置为开机启动的方法。分享给大家供大家参考。具体如下:
private void WriteRegistry()
{
string strName = Application.ExecutablePath;
if (File.Exists(strName))
{
string strNewName = Path.GetFileName(strName);
RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (reg == null)
{
reg = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
}
else
{
if (reg.GetValue(strNewName) == null)
{
reg.SetValue(strNewName, strName);
}
}
}
}
相关文章推荐
- C#使用Log4Net记录日志
- C#中深度复制和浅度复制详解
- C# VS2012下的3D显示(二)
- C#的事件处理机制
- C#遍历文件夹后上传文件夹中所有文件错误案例分析
- C# VS2012下的3D显示(一)
- C#编程自学之运算符和表达式
- Webform中Repeater控件--绑定嵌入C#代码四种方式
- C#常用算法帖:数组
- C#使用PrintDocument打印 多页 打印预览
- 【c#笔记】网页数据抓取
- c#datagrid的每行的单击事件
- C#中读取文件和写入文件的类
- C# 把控件内容导出图片
- C#中web获取路径
- 放松时刻——C#分割字符串
- C#将指定picturebox图片保存到本地
- C#使用Socket获取网页源代码
- C#入门(一):IDE
- C#入门(一):IDE