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;
}
}
}
本文地址:http://com.8s8s.com/it/it42347.htm