使用API在c#中重启PC [英] Using API to Restart a PC in c#
本文介绍了使用API在c#中重启PC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经编写了代码,但出于某种原因,当我点击
按钮时,什么也没发生。这是代码。
I've already got the code written but for some reason, when i click the
button, nothing occurs. Here is the code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
[DllImport("advapi32.dll",EntryPoint="InitiateSyste mShutdown")]
public static extern bool InitiateSystemShutdownA(string
lpMachineName, string lpMessage, int dwTimeout, int bForceAppsClosed, int
bRebootAfterShutdown);
private void button1_Click(object sender, System.EventArgs e)
{
InitiateSystemShutdownA(null,null, 30, 1, 1);
}
它编译得很好,但是当我点击button1时,没有任何反应。有什么想法吗?
It compiles fine, but when i click button1, nothing happens. Any ideas?
推荐答案
你有正确的权利吗?
这篇关于使用API在c#中重启PC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文