yangbo50304 2015-10-20 00:48 采纳率: 100%
浏览 3735
已采纳

Win7下如何屏蔽ctrl+alt+del键?

hook什么的已经失效了,而且将winlogon.exe挂起的方法有问题(挂起中按下ctrl+alt+del,再恢复时弹出了界面),请问还有别的方法没?不要汇编的,只要vc的

  • 写回答

5条回答

  • jok_219 2015-10-23 00:57
    关注

    win7下,登录页面是无法通过hook屏蔽的,因为系统登录页面会优先获取到组合键。我之前用过一个方法可以屏蔽ALT+CTRL+DEL,就是注入方式锁定登录页面管理进程**winlogon**,但是如果按了组合键只是暂时不触发,锁定解除后,还会继续触发。在某些情况下,还会造成卡登陆页面。所以我建议你通过注入方式锁定explorer进程,会好一点。进程锁定代码如下

     public static class ProcessFrozenController
        {
            private const int THREADACCESS_SUSPEND_RESUME = 0x0002;
    
            [DllImport("kernel32.dll", SetLastError = true)]
            private static extern IntPtr OpenThread(uint dwDesiredAccess, bool bInheritHandle, uint threadId);
    
            [DllImport("kernel32.dll", SetLastError = true)]
            private static extern int SuspendThread(IntPtr hThread);
    
            [DllImport("kernel32.dll", SetLastError = true)]
            private static extern int ResumeThread(IntPtr hThread);
    
            [DllImport("kernel32.dll")]
            private static extern uint GetLastError();
    
            [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
            private static extern bool CloseHandle(IntPtr hobject);
    
            public static bool FreezeProcess(string processName, ref string msg)
            {
                Process[] processArray = Process.GetProcesses();
                Process operateProcess = null;
    
                foreach (Process p in processArray)
                {
                    if (p.ProcessName.ToLower().Trim() != processName) continue;
    
                    operateProcess = p;
                    break;
                }
    
                if (operateProcess == null)
                {
                    msg = "未找到进程";
                    return false;
                }
    
                List<ProcessThread> handledList = new List<ProcessThread>();
                foreach (ProcessThread pthd in operateProcess.Threads)
                {
                    if (SuspendProcessThread(pthd))
                    {
                        handledList.Add(pthd);
                        continue;
                    }
    
                    foreach (ProcessThread hpthd in handledList)
                    {
                        ResumeProcessThread(hpthd);
                    }
    
                    msg = "冻结进程失败";
                    return false;
                }
                operateProcess.Dispose();
    
                return true;
            }
    
            public static void UnfreezeProcess(string processName)
            {
                Process[] processArray = Process.GetProcesses();
                Process operateProcess = null;
    
                foreach (Process p in processArray)
                {
                    if (p.ProcessName.ToLower().Trim() != processName) continue;
    
                    operateProcess = p;
                    break;
                }
    
                if (operateProcess == null)
                {
                    return;
                }
    
                foreach (ProcessThread thd in operateProcess.Threads)
                {
                    ResumeProcessThread(thd);
                }
                operateProcess.Dispose();
            }
    
            #region 私有函数
    
            private static bool SuspendProcessThread(ProcessThread thread)
            {
                IntPtr threadHandle = OpenThread(THREADACCESS_SUSPEND_RESUME, false, (uint)thread.Id); // Open thread with required permissions
                if (threadHandle == IntPtr.Zero) // If thread pointer is zero, means that the 'OpenThread' function has failed
                {
                    return false;
                }
                if (SuspendThread(threadHandle) == -1) // If the result is -1, the funtion has failed
                {
                    CloseHandle(threadHandle);
                    return false;
                }
                CloseHandle(threadHandle);
                return true;
            }
    
            private static bool ResumeProcessThread(ProcessThread thread)
            {
                IntPtr threadHandle = OpenThread(THREADACCESS_SUSPEND_RESUME, false, (uint)thread.Id); // Open thread with required permissions
                if (threadHandle == IntPtr.Zero) // If thread pointer is zero, means that the 'OpenThread' function has failed
                {
                    return false;
                }
                if (ResumeThread(threadHandle) == -1) // If the result is -1, the funtion has failed
                {
                    CloseHandle(threadHandle);
                    return false;
                }
                CloseHandle(threadHandle); // Don't forget close thread handle
                return true;
            }
    
            #endregion
        }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办