此方法调用时是让winlogo挂起,会涉及到不少问题,比如当挂起时无法关机、无法重启、进入睡眠或者关闭显示器后必须强制重启才
能进入系统、按下WIN+L切换账户时会一直显示登录界面的蓝色背景。恢复挂起后上述问题全部解决
#region 屏蔽管理器
[DllImport("ntdll.dll")]
public static extern int ZwSuspendProcess(IntPtr ProcessId);
[DllImport("ntdll.dll")]
public static extern int ZwResumeProcess(IntPtr ProcessId);
/// <summary>
/// 屏蔽管理器
/// </summary>
public static void SuspendWinLogon()
{
Process[] pc = Process.GetProcessesByName("winlogon");
if (pc.Length > 0)
{
ZwSuspendProcess(pc[0].Handle);
}
}
/// <summary>
/// 恢复管理器
/// </summary>
public static void ResumeWinLogon()
{
Process[] pc = Process.GetProcessesByName("winlogon");
if (pc.Length > 0)
{
ZwResumeProcess(pc[0].Handle);
}
}
#endregion
调用方式
/// <summary>
/// LOAD
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void key_Load(object sender, EventArgs e)
{
//屏蔽管理器
SuspendWinLogon();
}
/// <summary>
/// 关闭程序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void key_FormClosing(object sender, FormClosingEventArgs e)
{
//禁用恢复
ResumeWinLogon();
}