[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] VBS求注释

  1. Public Const ErrorSuccess = 0
  2. Public Const ProcessAllAccess = 2035711
  3. ' ### FUNCTION ###
  4. ' ===============================================================================================
  5. ' Name.................... : SuspendProcess()
  6. ' Description........... : Suspend/Resume a process specified.
  7. ' Requirements........ : DynWrap.dll   -
  8. '  : Kernel32.dll   - OpenProcess
  9. '  :    - CloseHandle
  10. '  : Ntdll.dll    - NtResumeProcess
  11. '  :    - NtSuspendProcess
  12. ' Syntax................... : SuspendProcess(iProcess, iFlag)
  13. ' Parameters............ : iProcess    - PID or Image name for a process.
  14. '  : iFlag    - Set this parameter to True to suspend a process, otherwise resume.
  15. ' Return values........ : Success    - ErrorSuccess
  16. '  : Failure    - 1, Process is not found.
  17. ' Author.................. : Pusofalse
  18. ' Modified............... :
  19. ' Remarks................ : To suspend process will lead the process is not responding.
  20. ' Related.................. :
  21. ' Link...................... :
  22. ' Examples............... : Suspend : SuspendProcess "notepad.exe", True
  23. '  : Resume : SuspendProcess "notepad.exe", False
  24. ' ===============================================================================================
  25. Function SuspendProcess(iProcess, iFlag)
  26. Dim oProcess, oItem, sWMI, i_Flag
  27. Set oProcess = GetObject("winmgmts:\\.\root\cimv2")
  28. If not IsNumeric(iProcess) then
  29.   sWMI = "Select ProcessId From Win32_Process where Name='" & iProcess & "'"
  30.   Set oItem = oProcess.ExecQuery(sWMI, , 48)
  31.   For Each ele In oItem
  32.    iProcess = ele.ProcessId
  33.   Next
  34. End If
  35. If not IsNumeric(iProcess) then
  36.   SuspendProcess = 1
  37.   Exit Function
  38. End If
  39. Dim hProcess, NtProcess, iResult
  40. Set NtProcess = CreateObject("DynamicWrapper")
  41. NtProcess.Register "kernel32.dll", "OpenProcess", "i=luu", "r=h"
  42. NtProcess.Register "kernel32.dll", "CloseHandle", "i=h", "r=u"
  43. NtProcess.Register "Ntdll.dll", "NtSuspendProcess", "i=h", "r=u"
  44. NtProcess.Register "Ntdll.dll", "NtResumeProcess", "i=h", "r=u"
  45. hProcess = NtProcess.OpenProcess(ProcessAllAccess, 0, iProcess)
  46. If iFlag = True Then
  47.   iResult = NtProcess.NtSuspendProcess(hProcess)
  48. Else
  49.   iResult = NtProcess.NtResumeProcess(hProcess)
  50. End If
  51. NtProcess.CloseHandle hProcess
  52. SuspendProcess = iResult
  53. Exit Function
  54. End Function '==> SuspendProcess()
复制代码
那位老大帮我做个注释下
小弟谢了
小弟看不懂

本帖最后由 applba 于 2012-1-15 21:37 编辑
  1. Public Const ErrorSuccess = 0
  2. Public Const ProcessAllAccess = 2035711
  3. ' ### 函数 ###
  4. ' ===============================================================================================
  5. ' 名称 SuspendProcess()
  6. ' 描述 挂起/恢复 指定的进程
  7. ' 要求  DynWrap.dll   -
  8. '         Kernel32.dll   - OpenProcess
  9. '                            - CloseHandle
  10. '         Ntdll.dll    - NtResumeProcess
  11. '                       - NtSuspendProcess
  12. ' 语法 SuspendProcess(iProcess, iFlag)
  13. ' 参数 iProcess    -  进程的PID或映象名称。
  14. '          iFlag    - 设置此参数为True时挂起进程,否则恢复。
  15. ' 返回值 成功    - ErrorSuccess
  16. '           失败    - 1(进程未找到)
  17. ' 作者.................. : Pusofalse
  18. ' Modified............... :
  19. ' 注释............... : To suspend process will lead the process is not responding.
  20. ' Related.................. :
  21. ' Link...................... :
  22. ' 例子:
  23. '挂起 SuspendProcess "notepad.exe", True
  24. '恢复 SuspendProcess "notepad.exe", False
  25. ' ===============================================================================================
复制代码

TOP

谢谢applba

TOP

返回列表