这是两年前写的了:-),现在从CSDN上搬过来.
using System;
using System.Runtime.InteropServices;
class test_BroadcastSystemMessage
{
const short BSF_POSTMESSAGE=0x10;
static short BSM_APPLICATIONS=0x8;
private const Int32 SC_RESTORE =0xF120;
const short WM_SYSCOMMAND = 0x112;
[DllImport("user32.dll")]
public static extern void BroadcastSystemMessage(short i,ref short ii, short iii, Int32 iiii, Int32 z);
static void Main()
{
Console.WriteLine("这个程序具有破坏性,请退出当前所有程序,\"Y\"执行;\"N\"退出当前程序");
string confirm=Console.ReadLine();
switch(confirm)
{
case "Y":
BroadcastSystemMessage(BSF_POSTMESSAGE,ref BSM_APPLICATIONS, WM_SYSCOMMAND, SC_RESTORE, 0);
break;
case "y":
BroadcastSystemMessage(BSF_POSTMESSAGE,ref BSM_APPLICATIONS, WM_SYSCOMMAND, SC_RESTORE, 0);
break;
case "N":
break;
case "n":
break;
default:
Console.WriteLine("请确入有效字符(Y/N),重新起动程序");
break;
}
}
}
posted on 2007-05-07 18:19
Boon 阅读(627)
评论(1) 编辑 收藏 引用 所属分类:
.Net Framework