记录某程序的运行时间

yanyi1210 2011-07-08 09:47:55
提问:怎样获取系统中某一个程序的运行时间?
例如:记录QQ每次的运行时间和运行次数。
要求:代码简洁易懂。
...全文
201 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
自由建客 2011-07-08
  • 打赏
  • 举报
回复
楼主没看到五楼和十楼吗?
ChrisAK 2011-07-08
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 yanyi1210 的回复:]

没那么复杂,就是指定的某个程序打开时,怎样获取到这个事件响应?
[/Quote]挂api钩子createprocess.
不过这样做90%的情况是你的程序会被傻毒软件干掉
yanyi1210 2011-07-08
  • 打赏
  • 举报
回复
没那么复杂,就是指定的某个程序打开时,怎样获取到这个事件响应?
小D 2011-07-08
  • 打赏
  • 举报
回复
乱七八糟啊
yanyi1210 2011-07-08
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 caozhy 的回复:]
提问:怎样登月
例如:我有一辆奥拓车,我想改造成飞船
要求:简洁易懂
[/Quote]
很复杂吗?啊??
足球中国 2011-07-08
  • 打赏
  • 举报
回复
.net自带了这个功能process类就有。
zjq8888882009 2011-07-08
  • 打赏
  • 举报
回复
学习!
自由建客 2011-07-08
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 gac520 的回复:]

按理说WINDOWS 里面应该有记录的啊、直接读取API不就可以了么?
[/Quote]
当然有记录了,要不 GetProcessTimes() 怎么工作,那玩意叫进程会计。
浪子-无悔 2011-07-08
  • 打赏
  • 举报
回复
按理说WINDOWS 里面应该有记录的啊、直接读取API不就可以了么?
ChrisAK 2011-07-08
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xuexiaodong2009 的回复:]

引用 3 楼 anbam 的回复:

1
死循环,不停扫描系统中正在运行的进程

2
写到一个dll动态链接库里,然后启动系统钩子,当任何一个进程启动时,我们的dll将会被加载到该进程中

3
外壳钩子可以监视各种Shell事件消息。比如启动和关闭应用程序。
外壳钩子可以监视各种Shell事件消息。比如启动和关闭应用程序。
[/Quote]钩子...弄那么复杂干嘛?
现成的API不用

GetProcessTimes Function

Retrieves timing information for the specified process.


BOOL WINAPI GetProcessTimes(
__in HANDLE hProcess,
__out LPFILETIME lpCreationTime,
__out LPFILETIME lpExitTime,
__out LPFILETIME lpKernelTime,
__out LPFILETIME lpUserTime
);

Parameters
hProcess
A handle to the process whose timing information is sought. This handle must be created with the PROCESS_QUERY_INFORMATION access right. For more information, see Process Security and Access Rights.

lpCreationTime
A pointer to a FILETIME structure that receives the creation time of the process.

lpExitTime
A pointer to a FILETIME structure that receives the exit time of the process. If the process has not exited, the content of this structure is undefined.

lpKernelTime
A pointer to a FILETIME structure that receives the amount of time that the process has executed in kernel mode. The time that each of the threads of the process has executed in kernel mode is determined, and then all of those times are summed together to obtain this value.

lpUserTime
A pointer to a FILETIME structure that receives the amount of time that the process has executed in user mode. The time that each of the threads of the process has executed in user mode is determined, and then all of those times are summed together to obtain this value.
xuexiaodong2009 2011-07-08
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 anbam 的回复:]

1
死循环,不停扫描系统中正在运行的进程

2
写到一个dll动态链接库里,然后启动系统钩子,当任何一个进程启动时,我们的dll将会被加载到该进程中

3
外壳钩子可以监视各种Shell事件消息。比如启动和关闭应用程序。
[/Quote]外壳钩子可以监视各种Shell事件消息。比如启动和关闭应用程序。
anbam 2011-07-08
  • 打赏
  • 举报
回复
1
死循环,不停扫描系统中正在运行的进程

2
写到一个dll动态链接库里,然后启动系统钩子,当任何一个进程启动时,我们的dll将会被加载到该进程中

3
外壳钩子可以监视各种Shell事件消息。比如启动和关闭应用程序。
缭绕飘渺 2011-07-08
  • 打赏
  • 举报
回复
判断进程是否可行
进程启动开始计时
结束时计时结束
同时次数++
threenewbee 2011-07-08
  • 打赏
  • 举报
回复
提问:怎样登月
例如:我有一辆奥拓车,我想改造成飞船
要求:简洁易懂

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧