两个小知识:C#如何设置开机启动时自动执行程序|C# WinForm打开超链接
生活随笔
收集整理的這篇文章主要介紹了
两个小知识:C#如何设置开机启动时自动执行程序|C# WinForm打开超链接
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
通過在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.exe",?"http://revit.5d6d.com");
????????}
????}
}
源碼:http://revit.5d6d.com/thread-896-1-1.html
在注冊表的"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.exe",?"http://revit.5d6d.com");
????????}
????}
}
源碼:http://revit.5d6d.com/thread-896-1-1.html
轉載于:https://www.cnblogs.com/greatverve/archive/2011/05/09/csharp-startup.html
總結
以上是生活随笔為你收集整理的两个小知识:C#如何设置开机启动时自动执行程序|C# WinForm打开超链接的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用IShellView接口函数Crea
- 下一篇: Ethernet