C# 开机启动
本文最后更新于 230 天前,其中的信息可能已经有所发展或是发生改变。
using Microsoft.Win32;
using System.Diagnostics;

public class AutoStart
{
    public const string KeyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";

    public static void Set(bool value)
    {
        using (var key = Registry.CurrentUser.OpenSubKey(KeyPath, true))
        {
            var process = Process.GetCurrentProcess();
            if (value)
            {
                key.SetValue(process.ProcessName, process.MainModule.FileName);
            }
            else
            {
                key.DeleteValue(process.ProcessName, false);
            }
        }
    }

    public static bool IsEnabled()
    {
        using (var key = Registry.CurrentUser.OpenSubKey(KeyPath))
        {
            var process = Process.GetCurrentProcess();
            return key.GetValue(process.ProcessName) != null;
        }
    }
}
作者:AlexSJC
本文采用 CC BY-NC-ND 4.0 许可协议
暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇