惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - Gofficer

决战紫禁之巅 为学 C#网页自动登录和提交POST信息的多种方法 一个C#写的调用外部进程类 快速实现在Windows应用程序中支持拖拽的TreeView控件(C#) PPT转图片 开发人员,敢问路在何方? ultraGrid 控件中,实现单元格内容换行显示 如何用一条sql取得第10到第20条的记录? 用Sandcastle一键生成CHM帮助文档 实现服务器端与客户端对话 C#中访问WEB页面 使用代理服务器 自定义Ping方法 HTTP请求和应答 Socket套接字实现服务器端连接 Socket套接字实现客户端连接 启动和停止本地系统进程 异常处理
C# 实现注销、关机、重启电脑功能
Gofficer · 2008-01-10 · via 博客园 - Gofficer

  using System.Runtime.InteropServices;
[Flags]
        
public enum ExitWindows : uint
        
{
            LogOff 
= 0x00,      //注销
            ShutDown = 0x01,    //关机
            Reboot = 0x02,      //重启
            Force = 0x04,
            PowerOff 
= 0x08,
            ForceIfHung 
= 0x10
        }


        [Flags]
        
public enum ShutdownReason : uint
        
{
            MajorApplication 
= 0x00040000,
            MajorHardware 
= 0x00010000,
            MajorLegacyApi 
= 0x00070000,
            MajorOperatingSystem 
= 0x00020000,
            MajorOther 
= 0x00000000,
            MajorPower 
= 0x00060000,
            MajorSoftware 
= 0x00030000,
            MajorSystem 
= 0x00050000,

            MinorBlueScreen 
= 0x0000000F,
            MinorCordUnplugged 
= 0x0000000b,
            MinorDisk 
= 0x00000007,
            MinorEnvironment 
= 0x0000000c,
            MinorHardwareDriver 
= 0x0000000d,
            MinorHotfix 
= 0x00000011,
            MinorHung 
= 0x00000005,
            MinorInstallation 
= 0x00000002,
            MinorMaintenance 
= 0x00000001,
            MinorMMC 
= 0x00000019,
            MinorNetworkConnectivity 
= 0x00000014,
            MinorNetworkCard 
= 0x00000009,
            MinorOther 
= 0x00000000,
            MinorOtherDriver 
= 0x0000000e,
            MinorPowerSupply 
= 0x0000000a,
            MinorProcessor 
= 0x00000008,
            MinorReconfig 
= 0x00000004,
            MinorSecurity 
= 0x00000013,
            MinorSecurityFix 
= 0x00000012,
            MinorSecurityFixUninstall 
= 0x00000018,
            MinorServicePack 
= 0x00000010,
            MinorServicePackUninstall 
= 0x00000016,
            MinorTermSrv 
= 0x00000020,
            MinorUnstable 
= 0x00000006,
            MinorUpgrade 
= 0x00000003,
            MinorWMI 
= 0x00000015,

            FlagUserDefined 
= 0x40000000,
            FlagPlanned 
= 0x80000000
        }


        [DllImport(
"user32.dll")]
        
static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);

        [STAThread]
        
static void Main(string[] args)
        
{
            ExitWindowsEx(ExitWindows.LogOff, ShutdownReason.MajorOther 
& ShutdownReason.MinorOther);
            
//这个语句将实现计算机注销操作   
        }