关于 GetProcessTimes方法的使用

mishuilin 2005-07-19 05:07:56
我想得到进程的运行时间,我知道使用GetProcessTimes这个函数,但我不会用,有谁能告诉我一下怎么用吗?
最好能给个示例代码。

GetProcessTimes
The GetProcessTimes function obtains timing information about a specified process.

BOOL GetProcessTimes(
HANDLE hProcess, // specifies the process of interest
LPFILETIME lpCreationTime, // when the process was created
LPFILETIME lpExitTime, // when the process exited
LPFILETIME lpKernelTime, // time the process has spent in kernel
// mode
LPFILETIME lpUserTime // time the process has spent in user mode
);

...全文
1761 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mishuilin 2005-07-21
  • 打赏
  • 举报
回复
谢谢大家,问题已经解决!我是这样做的:
FILETIME l1,l2,l3,l4;
GetProcessTimes(hTime,&l1,&l2,&l3,&l4);
CTime cc(l1);
CSstring str = cc.Format("%Y-%m-%d %X");
这样就成了!
亿云力科技 2005-07-21
  • 打赏
  • 举报
回复
BOOL FileTimeToSystemTime(
CONST FILETIME *lpFileTime, // file time to convert
LPSYSTEMTIME lpSystemTime // receives system time
);

再调用sprintf()把SYSTEMTIME各个字段写到一个buffer里
mishuilin 2005-07-20
  • 打赏
  • 举报
回复
谢谢大家,我已经能读到时间了,
但对LPFILETIME 行的数据怎么处理得到string行的数据呢?
我一对LPFILETIME 数据处理, 程序运行就出错!
AtaLoss0202 2005-07-19
  • 打赏
  • 举报
回复
第一个参数:要获取信息的进程的句柄
第二个参数:进程建立的时间
第三个参数:进程结束的时间
第四个参数:进程在核心模式下消耗的时间
第五个参数:进程在用户模式下消耗的时间
第2-5个参数都必须传递一个变量以接收数据,然后访问这些变量就可以得到你要的信息了.
yazi321 2005-07-19
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocesstimes.asp
OpenHero 2005-07-19
  • 打赏
  • 举报
回复
baidu google

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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