标题: [问题求助] VBS求注释 [打印本页]
作者: bbpp5200 时间: 2012-1-15 13:32 标题: VBS求注释
- Public Const ErrorSuccess = 0
- Public Const ProcessAllAccess = 2035711
-
- ' ### FUNCTION ###
- ' ===============================================================================================
- ' Name.................... : SuspendProcess()
- ' Description........... : Suspend/Resume a process specified.
- ' Requirements........ : DynWrap.dll -
- ' : Kernel32.dll - OpenProcess
- ' : - CloseHandle
- ' : Ntdll.dll - NtResumeProcess
- ' : - NtSuspendProcess
- ' Syntax................... : SuspendProcess(iProcess, iFlag)
- ' Parameters............ : iProcess - PID or Image name for a process.
- ' : iFlag - Set this parameter to True to suspend a process, otherwise resume.
- ' Return values........ : Success - ErrorSuccess
- ' : Failure - 1, Process is not found.
- ' Author.................. : Pusofalse
- ' Modified............... :
- ' Remarks................ : To suspend process will lead the process is not responding.
- ' Related.................. :
- ' Link...................... :
- ' Examples............... : Suspend : SuspendProcess "notepad.exe", True
- ' : Resume : SuspendProcess "notepad.exe", False
- ' ===============================================================================================
- Function SuspendProcess(iProcess, iFlag)
- Dim oProcess, oItem, sWMI, i_Flag
- Set oProcess = GetObject("winmgmts:\\.\root\cimv2")
- If not IsNumeric(iProcess) then
- sWMI = "Select ProcessId From Win32_Process where Name='" & iProcess & "'"
- Set oItem = oProcess.ExecQuery(sWMI, , 48)
- For Each ele In oItem
- iProcess = ele.ProcessId
- Next
- End If
- If not IsNumeric(iProcess) then
- SuspendProcess = 1
- Exit Function
- End If
- Dim hProcess, NtProcess, iResult
- Set NtProcess = CreateObject("DynamicWrapper")
- NtProcess.Register "kernel32.dll", "OpenProcess", "i=luu", "r=h"
- NtProcess.Register "kernel32.dll", "CloseHandle", "i=h", "r=u"
- NtProcess.Register "Ntdll.dll", "NtSuspendProcess", "i=h", "r=u"
- NtProcess.Register "Ntdll.dll", "NtResumeProcess", "i=h", "r=u"
- hProcess = NtProcess.OpenProcess(ProcessAllAccess, 0, iProcess)
- If iFlag = True Then
- iResult = NtProcess.NtSuspendProcess(hProcess)
- Else
- iResult = NtProcess.NtResumeProcess(hProcess)
- End If
- NtProcess.CloseHandle hProcess
- SuspendProcess = iResult
- Exit Function
- End Function '==> SuspendProcess()
复制代码
那位老大帮我做个注释下
小弟谢了
小弟看不懂
作者: applba 时间: 2012-1-15 21:32
本帖最后由 applba 于 2012-1-15 21:37 编辑
- Public Const ErrorSuccess = 0
- Public Const ProcessAllAccess = 2035711
-
- ' ### 函数 ###
- ' ===============================================================================================
- ' 名称 SuspendProcess()
- ' 描述 挂起/恢复 指定的进程
- ' 要求 DynWrap.dll -
- ' Kernel32.dll - OpenProcess
- ' - CloseHandle
- ' Ntdll.dll - NtResumeProcess
- ' - NtSuspendProcess
- ' 语法 SuspendProcess(iProcess, iFlag)
- ' 参数 iProcess - 进程的PID或映象名称。
- ' iFlag - 设置此参数为True时挂起进程,否则恢复。
- ' 返回值 成功 - ErrorSuccess
- ' 失败 - 1(进程未找到)
- ' 作者.................. : Pusofalse
- ' Modified............... :
- ' 注释............... : To suspend process will lead the process is not responding.
- ' Related.................. :
- ' Link...................... :
- ' 例子:
- '挂起 SuspendProcess "notepad.exe", True
- '恢复 SuspendProcess "notepad.exe", False
- ' ===============================================================================================
复制代码
作者: bbpp5200 时间: 2012-1-16 00:50
谢谢applba
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |