用VB 关闭其他应用程序

前端之家收集整理的这篇文章主要介绍了用VB 关闭其他应用程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1

 
 
  1. PrivateDeclareFunctionCreateToolhelp32SnapshotLib"kernel32"(ByValdwFlagsAsLong,ByValth32ProcessIDAsLong)AsLong
  2. PrivateDeclareFunctionProcess32FirstLib"kernel32"(ByValhSnapshotAsLong,lppeAsPROCESSENTRY32)AsLong
  3. PrivateDeclareFunctionProcess32NextLib"kernel32"(ByValhSnapshotAsLong,lppeAsPROCESSENTRY32)AsLong
  4. PrivateDeclareFunctionCloseHandleLib"kernel32"(ByValhObjectAsLong)AsLong
  5. PrivateDeclareFunctionOpenProcessLib"kernel32"(ByValdwDesiredAccessAsLong,ByValblnheritHandleAsLong,ByValdwAppProcessIdAsLong)AsLong
  6. PrivateDeclareFunctionTerminateProcessLib"kernel32"(ByValApPHProcessAsLong,ByValuExitCodeAsLong)AsLong
  7. PrivateTypePROCESSENTRY32
  8. dwSizeAsLong
  9. cntUsageAsLong
  10. th32ProcessIDAsLong
  11. th32DefaultHeapIDAsLong
  12. th32ModuleIDAsLong
  13. cntThreadsAsLong
  14. th32ParentProcessIDAsLong
  15. pcPriClassBaseAsLong
  16. dwFlagsAsLong
  17. szExeFileAsString*1024
  18. EndType
  19. ConstTH32CS_SNAPHEAPLIST=&H1
  20. ConstTH32CS_SNAPPROCESS=&H2
  21. ConstTH32CS_SNAPTHREAD=&H4
  22. ConstTH32CS_SNAPMODULE=&H8
  23. ConstTH32CS_SNAPALL=(TH32CS_SNAPHEAPLISTOrTH32CS_SNAPPROCESSOrTH32CS_SNAPTHREADOrTH32CS_SNAPMODULE)
  24. ConstTH32CS_INHERIT=&H80000000
  25. DimpidAsLong
  26. DimpnameAsString
  27. PrivateSubtaskkill(ByValtasknameAsString)
  28. DimmyAsPROCESSENTRY32
  29. DimlAsLong
  30. Diml1AsLong
  31. DimflagAsBoolean
  32. DimmNameAsString
  33. DimiAsInteger
  34. l=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0)
  35. IflThen
  36. my.dwSize=1060
  37. If(Process32First(l,my))Then
  38. Do
  39. i=InStr(1,my.szExeFile,Chr$(0))
  40. mName=LCase$(Left$(my.szExeFile,i-1))
  41. IfmName=LCase$(taskname)Then
  42. pid=my.th32ProcessID
  43. pname=mName
  44. DimmProcIDAsLong
  45. mProcID=OpenProcess(1&,-1&,pid)
  46. TerminateProcessmProcID,0&
  47. flag=True
  48. Else
  49. flag=False
  50. EndIf
  51. LoopUntil(Process32Next(l,my)<1)
  52. l1=CloseHandle(l)
  53. EndIf
  54. EndIf
  55. EndSub
  56. '×¢Òâ½ø³ÌÃûÒªÇø·Ö´óСд
  57. PrivateSubCommand1_Click()
  58. '
  59. Calltaskkill("calc.exe")
  60. EndSub

猜你在找的VB相关文章