首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >winappdbg:使用kernel32函数

winappdbg:使用kernel32函数
EN

Stack Overflow用户
提问于 2011-12-06 14:46:43
回答 1查看 576关注 0票数 0

我尝试使用函数GetProcessTimes(hprocess)。

我使用以下代码:

代码语言:javascript
复制
p = debug.excel(argv,bFollow=True)
win32.kernel32.GetProcessTimes(p)

但这行不通..。

此函数采用4个参数(5个给定)

有人能帮忙吗?我忘了什么?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2011-12-06 15:35:28

我可以建议你自己打电话吗?(取自python 长椅本身):

代码语言:javascript
复制
# if you have win32 process
import win32process
def getprocesstimes_systimes():
    d = win32process.GetProcessTimes(win32process.GetCurrentProcess())
    return (d['UserTime'] / WIN32_PROCESS_TIMES_TICKS_PER_SECOND,
        d['KernelTime'] / WIN32_PROCESS_TIMES_TICKS_PER_SECOND)

# otherwise, ctypes approach
import ctypes
def getprocesstimes_systimes():
    creationtime = ctypes.c_ulonglong()
    exittime = ctypes.c_ulonglong()
    kerneltime = ctypes.c_ulonglong()
    usertime = ctypes.c_ulonglong()
    rc = ctypes.windll.kernel32.GetProcessTimes(
        ctypes.windll.kernel32.GetCurrentProcess(),
        ctypes.byref(creationtime),
        ctypes.byref(exittime),
        ctypes.byref(kerneltime),
        ctypes.byref(usertime))
    if not rc:
        raise TypeError('GetProcessTimes() returned an error')
    return (usertime.value / WIN32_PROCESS_TIMES_TICKS_PER_SECOND,
            kerneltime.value / WIN32_PROCESS_TIMES_TICKS_PER_SECOND)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8401753

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档