Board logo

标题: [问题求助] VBS求注释 [打印本页]

作者: bbpp5200    时间: 2012-1-15 13:32     标题: 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:32

本帖最后由 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. ' ===============================================================================================
复制代码

作者: bbpp5200    时间: 2012-1-16 00:50

谢谢applba





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2