找出使用.net应用程序打开Outlook的时间. [英] find out outlook was open for how much time using .net application.

查看:109
本文介绍了找出使用.net应用程序打开Outlook的时间.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有如下要求.


每天结束时,.NET应用程序都应计算在计算机上打开Outlook的时间.



请帮助我如何执行此任务.

We have a requirement as below.


At the end of every day, the .NET application should calculate for how much time the Outlook was open on the computer.



Please help me how can I do this task.

推荐答案

您可以构建Windows服务,该服务定期检查进程"outlook.exe"是否正在运行,是否正在运行然后您的服务将开始跟踪使用时间.
You can build a windows service, that periodical checks if process "outlook.exe" is running, if it is then your service starts tracking usage time.


除了LNogueira已经说过的内容之外,您还可以使用 Win32 API 的aspx"target =" _ blank"title =" New Window> ^ ](您可以直接从 C ++ 使用它,也可以通过从 C# VB ).

如果将 outlook.exe 的进程句柄传递给此函数,并且第二个参数等于INFINITE(在WinBase.h中将INFINITE定义为0xFFFFFFFF),则该函数不会返回,直到指定的进程终止(终止的方式无关紧要).

然后您可以通过以下方式进行操作:

In addition to what LNogueira already said, you can use the WaitForSingleObject Function (Windows)[^] from the Win32 API (you can use it directly from C++ or by marshalling from C# and VB).

If you pass the process handle of outlook.exe to this function, with the second parameter equal to INFINITE (INFINITE is defined in WinBase.h as 0xFFFFFFFF), the function does not return until the specified process terminates (it doesn''t matter how it terminates).

Then you can work this way:


  1. 测试进程 outlook.exe 是否正在运行
  2. 如果 outlook.exe 未运行,请稍等片刻,然后返回步骤( 1);否则,继续执行步骤(3)
  3. 保存当前时间(这是开始Outlook的时间)
  4. 获取 outlook.exe的句柄进程
  5. 调用WaitForSingleObject等待 outlook.exe 进程终止
  6. 获取当前时间并更新统计信息
  7. 返回步骤(1)

  1. Test if the process outlook.exe is running
  2. If outlook.exe is not running wait for a while then return to the step (1); otherwise go on with the step (3)
  3. Save the current time (this is the time when outlook is started)
  4. Get the handle of the outlook.exe process
  5. Call WaitForSingleObject to wait until the outlook.exe process terminates
  6. Get the current time and update your statistics
  7. Return to the step (1)


这篇关于找出使用.net应用程序打开Outlook的时间.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆