有个api函数可以得到系统启动的进行,不过关机的时间不好办,而且要直接调用dll。
你可以通过分析eventlog也能得到开关机的时间,eventlog直接使用.net中的组件就可以了。

解决方案 »

  1.   

    http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=3D86DE5B-D7A6-4CC4-23F1-EA54CC2E9422
      

  2.   

    在c# 里新建一个window service 程序。 就已经有两个方法onstart onstop 方法。
    把service 设为启动时自动运行。
    正常关机应该会先执行onstop //这个不太确定。我再找找资料。 protected override void OnStart(string[] args)
    {
      //启动了,记录时间
    }protected override void OnStop()
    {
      //关机时,记录时间
    }
      

  3.   

    Windows Services must be started and stopped, which can happen automatically. You can configure a Windows Service to start automatically at bootup, and of course it stops when a system is shut down.做windows service。