屏幕锁定源程序(屏蔽一般的系统热键以及键盘上任何你想要屏蔽的按键)

来源:互联网 发布:网站主域名是什么 编辑:程序博客网 时间:2024/05/18 02:08

功能:可以屏蔽系统热键,如ctrl+alt+del、ctrl+esc以及屏蔽掉一些软件的热键 

void CLockScreenDlg::Onlock()
{
 // TODO: Add your control notification handler code here
 CString str_password,str_confirm;
 GetDlgItemText(IDC_EDIT1,str_password);
 GetDlgItemText(IDC_EDIT2,str_confirm);
 if(str_password.Compare(str_confirm)!=0 || str_password.IsEmpty())
 {
  MessageBox("密码为空或不匹配!请重新输入!");
 }
 else
 {
  password=str_password;
  SetDlgItemText(IDC_EDIT1,"");
  SetDlgItemText(IDC_EDIT2,"");
  SendDlgItemMessage(IDC_EDIT2,EM_SETREADONLY,1);
  CRect rct;
  GetWindowRect(rct);
  ClipCursor(rct);
  SystemParametersInfo(SPI_SETSCREENSAVERRUNNING,true,0,SPIF_UPDATEINIFILE);
  CtrlAltDel_Enable_Disable(false);//屏蔽ctrl+alt+del
  TaskSwitching_Enable_Disable(false);//屏蔽alt+tab
  //调用maskkey.dll
  DWORD dwVK[] = {VK_SHIFT,VK_CONTROL,VK_DELETE,VK_ESCAPE,VK_LWIN, VK_RWIN};
  int nLength = sizeof(dwVK) / sizeof(DWORD);
  StartMaskKey(dwVK, nLength);
 }