通过在Microsft.Win32命名空间的Registry可以在注册表中设置注册表项中的名称/值对的值。
在注册表的”HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run”中
存储应用程序名和路径可以实现程序的自启动。

通过在Microsft.Win32命名空间的Registry可以在注册表中设置注册表项中的名称/值对的值。
在注册表的”HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run”中
存储应用程序名和路径可以实现程序的自启动。代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace AutoRun
{
    
public partial class Form1 : Form
    {
        
public Form1()
        {
            InitializeComponent();
        }
        
//设置开机启动
        private void btnSet_Click(object sender, EventArgs e)
        {
            Microsoft.Win32.Registry.SetValue(
@”HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
                , Application.ProductName, Application.StartupPath 
+ Application.ProductName);
        }
        
//C# WinForm打开超链接
        private void Form1_Load(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(
iexplore.exehttp://revit.5d6d.com);
        }
    }
}


源码:http://revit.5d6d.com/thread-896-1-1.html

版权声明:本文为greatverve原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/greatverve/archive/2011/05/09/2040495.html