
Nguyên bản được gửi bởi
thienthanit
Mình không cần cái này, phải hiện lên cửa sổ thông báo, phương thức hổ trợ này chỉ là thay cho khi bạn gõ vào Run thôi mà, vào thư mục Window xóa đi file shutdown.exe là hết dùng được, mình cần cái chính quy
Mai mốt có hỏi thì hỏi cho rõ ràng, dứt khoát nhé, lần này cho cậu dùng API:
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;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int uFlags, int dwReason);
private void btnShutDown_Click(object sender, EventArgs e)
{
ExitWindowsEx(1, 0);
}
private void btnReboot_Click(object sender, EventArgs e)
{
ExitWindowsEx(2, 0);
}
}
}
Thế có cần thêm cách khác nữa không?