using System.Runtime.InteropServices;using System.Text; [DllImport("user32")] public static extern long SetWindowPos(long hwnd,long hWndInsertAfter,long X,long y,long cx,long cy,long wFlaglong); [DllImport("user32")] public static extern long ExitWindowsEx(long uFlags, long dwReserved); [DllImport("shell32")] public static extern long ShellAbout(long uFlags, long deReserved);namespace 关闭windows{ public partial class frmmain : Form { long dwReserved; const int SHUTDOWN=1; const int REBOOT =2; const int LOGOFF=0; long sh; int counter,n; public frmmain() { InitializeComponent(); } private void frmmain_Load(object sender, System.EventArgs e) { //用系统时间初始化组件 TxtTime.Text = System.DateTime.Today.ToShortDateString() + "" + System.DateTime.Today.ToLongDateString(); } private void Timer1_Tick(object sender, System.EventArgs e) { //接受当前日期和时间,用于即时显示 string CurrDate = System.DateTime.Today.ToShortDateString(); string CurrTime = System.DateTime.Today.ToLongDateString(); //随时检测设定的官即日起和时间是否有效 if (this.CheckBox1.Checked == true) { if (CurrDate == SetupDate.ToString() && CurrTime == SetupTime.ToString()) ColseComputer(); } } private void ColseComputer() { sh = ExitWindowsEx(SHUTDOWN, dwReserved); } private void ButSysInfo_Click(object sender,System.EventArgs e) { Form2 frm=new Form2(); frm.Show(); } private void ButReOpen_Click(object sender,System.EventArgs e) { sh =ExitWindowsEx(REBOOT,dwReserved); } private void ButReLogin_Click(object sender,System.EventArgs e) { sh=ExitWindowsEx(LOGOFF,dwReserved); } private void ButCancel_Click(object sender,System.EventArgs e) { this.Close(); } private void ButClose_Click_l(object sender,System.EventArgs e) { sh =ExitWindowsEx(REBOOT,dwReserved)
1条回答
关注 不知道你这个问题是否已经解决, 如果还没有解决的话:- 这篇文章:c#游戏客户端编程 也许能够解决你的问题,你可以看下
如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
- ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
- ¥15 扩散模型sd.webui使用时报错“Nonetype”
- ¥15 stm32流水灯+呼吸灯+外部中断按键
- ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
- ¥15 NX MCD仿真与博途通讯不了啥情况
- ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
- ¥15 gradio的web端页面格式不对的问题
- ¥15 求大家看看Nonce如何配置
- ¥15 Matlab怎么求解含参的二重积分?