程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> 禁用Alt-Tab或Ctrl-Alt-Del

禁用Alt-Tab或Ctrl-Alt-Del

編輯:VB綜合教程
PrivateDeclareFunctionEnableWindowLib"user32"(ByValhWndAsInteger,ByValaBOOLAsInteger)AsInteger
  PrivateDeclareFunctionIsWindowEnabledLib"user32"(ByValhWndAsInteger)AsInteger
  PrivateDeclareFunctionGetMenuLib"user32"(ByValhWndAsInteger)AsInteger
  PrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString,ByVallpWindowNameAsString)AsLong
  PrivateDeclareFunctionSystemParametersInfoLib"user32"Alias"SystemParametersInfoA"(ByValuActionAsLong,ByValuParamAsLong,ByVallpvParamAsAny,ByValfuWinIniAsLong)AsLong
  PrivateTaskBarhWndAsLong
  PrivateIsTaskBarEnabledAsInteger
  PrivateTaskBarMenuHwndAsInteger

'禁止或允許使用Alt-Tab
  SubFastTaskSwitching(bEnabledAsBoolean)
  DimXAsLong,bDisabledAsLong
  bDisabled=NotbEnabled
  X=SystemParametersInfo(97,bDisabled,CStr(1),0)
  EndSub

'禁止使用Ctrl-Alt-Del
  PublicSubDisableTaskBar()
  DimEWindowAsInteger
  TaskBarhWnd=FindWindow("Shell_traywnd","")
  IfTaskBarhWnd<>0Then
  EWindow=IsWindowEnabled(TaskBarhWnd)
  IfEWindow=1Then
  IsTaskBarEnabled=EnableWindow(TaskBarhWnd,0)
  EndIf
  EndIf
  EndSub
  
  '允許使用Ctrl-Alt-Del
  
  PublicSubEnableTaskBar()
  IfIsTaskBarEnabled=0Then
  IsTaskBarEnabled=EnableWindow(TaskBarhWnd,1)
  EndIf
  EndSub
  
  '禁止Ctrl Alt Del
  '聲明(ForWin95):
  
  ConstSPI_SCREENSAVERRUNNING=97
  PrivateDeclareFunctionSystemParametersInfoLib"user32"Alias"SystemParametersInfoA"(ByValuActionAsLong,ByValuParamAsLong,lpvParamAsAny,ByValfuWinIniAsLong)AsLong
  使用:
  '禁止
  DimpOldAsBoolean
  CallSystemParametersInfo(SPI_SCREENSAVERRUNNING,True,pOld,0)
  '開啟
  DimpOldAsBoolean
  CallSystemParametersInfo(SPI_SCREENSAVERRUNNING,False,pOld,0)

->

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved