當(dāng)前位置:
首頁(yè) >
两个小知识:C#如何设置开机启动时自动执行程序|C# WinForm打开超链接
發(fā)布時(shí)間:2023/12/20
42
豆豆
生活随笔
收集整理的這篇文章主要介紹了
两个小知识:C#如何设置开机启动时自动执行程序|C# WinForm打开超链接
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
通過(guò)在Microsft.Win32命名空間的Registry可以在注冊(cè)表中設(shè)置注冊(cè)表項(xiàng)中的名稱/值對(duì)的值。
在注冊(cè)表的"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"中
存儲(chǔ)應(yīng)用程序名和路徑可以實(shí)現(xiàn)程序的自啟動(dòng)。代碼如下: 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();
????????}
????????//設(shè)置開機(jī)啟動(dòng)
????????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
在注冊(cè)表的"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"中
存儲(chǔ)應(yīng)用程序名和路徑可以實(shí)現(xiàn)程序的自啟動(dòng)。代碼如下: 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();
????????}
????????//設(shè)置開機(jī)啟動(dòng)
????????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
轉(zhuǎn)載于:https://www.cnblogs.com/greatverve/archive/2011/05/09/csharp-startup.html
總結(jié)
以上是生活随笔為你收集整理的两个小知识:C#如何设置开机启动时自动执行程序|C# WinForm打开超链接的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 使用IShellView接口函数Crea
- 下一篇: C#学习笔记五面向对象基础