retrieving date& time from elapsed time string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ccodenewbie
    New Member
    • Mar 2012
    • 1

    retrieving date& time from elapsed time string

    Hi All,

    This is a bit tricky to explain so please bear with me.

    I am trying to get Window's "System" process starttime. The closest I have come to doing so is by using
    Code:
     long st = procs.StartTime.ToFileTime();
    DateTime Dt = new DateTime(1601, 1, 1,0,0,0).AddSeconds(st);
    string stime = String.Empty;
    stime += (Environment.TickCount / 86400000).ToString() + ",";
    stime += (Environment.TickCount / 3600000 % 24) + ",";
    stime += (Environment.TickCount / 120000 % 60) + ",";
    stime += (Environment.TickCount / 1000 % 60);
    which gives me (for e.g) 7,10,22,48

    How can I convert the stime string into a datetime so that I can subtract it from DateTime.Now to get the process's starttime in the format dd/MM/yyyy HH:mm:ss?

    This doesn't work btw
    Code:
    DateTime result = DateTime.Now - new TimeSpan (stime);
Working...