Click here to Skip to main content
15,890,579 members
Home / Discussions / C#
   

C#

 
AnswerRe: same enumeration, different results? Pin
Luc Pattyn19-Mar-12 14:56
sitebuilderLuc Pattyn19-Mar-12 14:56 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 0:48
CCodeNewbie20-Mar-12 0:48 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 0:48
CCodeNewbie20-Mar-12 0:48 
GeneralRe: same enumeration, different results? Pin
PIEBALDconsult20-Mar-12 3:34
mvePIEBALDconsult20-Mar-12 3:34 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 8:29
CCodeNewbie20-Mar-12 8:29 
GeneralRe: same enumeration, different results? Pin
PIEBALDconsult20-Mar-12 11:03
mvePIEBALDconsult20-Mar-12 11:03 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 12:08
CCodeNewbie20-Mar-12 12:08 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 2:30
CCodeNewbie20-Mar-12 2:30 
Still not perfect - but it works (Improvements very welcome)
C#
TimeSpan uptime = TimeSpan.Zero;
using (PerformanceCounter ut = new PerformanceCounter("System", "System Up Time"))
    {
        ut.NextValue();
        uptime = TimeSpan.FromSeconds(ut.NextValue());
    }
    Console.WriteLine(uptime.ToString());
//result - 03:53:39.7870000

Process[] processlist = Process.GetProcesses();
foreach (Process procs in processlist)
{
    if (procs.ProcessName == "System")
    {
        long st = procs.StartTime.ToFileTime();
        DateTime stDt = new DateTime(1601, 1, 1).AddSeconds(st);
        float Days = (Environment.TickCount / 86400000);
        int dd = (int)Days;
        float Hours = (Environment.TickCount / 3600000 % 24);
        int HH = (int)Hours;
        float Mins = (Environment.TickCount / 60000 % 60);
        int mm = (int)Mins;
        float Secs = (Environment.TickCount / 1000 % 60);
        int ss = (int)Secs;
        DateTime result = DateTime.Now - new TimeSpan(dd, HH, mm, ss);
    }
}
//result - 20/03/2012 08:31:33

code run @ ~ 12:24 pm
GeneralRe: same enumeration, different results? Pin
Alan N20-Mar-12 3:39
Alan N20-Mar-12 3:39 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 8:33
CCodeNewbie20-Mar-12 8:33 
GeneralRe: same enumeration, different results? Pin
Alan N20-Mar-12 10:47
Alan N20-Mar-12 10:47 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 12:00
CCodeNewbie20-Mar-12 12:00 
AnswerWrongMagicConstantInHorribleCodeException Pin
Luc Pattyn19-Mar-12 13:03
sitebuilderLuc Pattyn19-Mar-12 13:03 
GeneralRe: WrongMagicConstantInHorribleCodeException Pin
CCodeNewbie19-Mar-12 13:05
CCodeNewbie19-Mar-12 13:05 
GeneralRe: WrongMagicConstantInHorribleCodeException Pin
CCodeNewbie19-Mar-12 13:08
CCodeNewbie19-Mar-12 13:08 
Answerfloat maxDaysInInt=((float)int.MaxValue)/1000/60/60/24; Pin
Luc Pattyn19-Mar-12 13:25
sitebuilderLuc Pattyn19-Mar-12 13:25 
GeneralRe: float maxDaysInInt=((float)int.MaxValue)/1000/60/60/24; Pin
CCodeNewbie20-Mar-12 2:32
CCodeNewbie20-Mar-12 2:32 
AnswerRe: same enumeration, different results? Pin
Alan N19-Mar-12 13:29
Alan N19-Mar-12 13:29 
GeneralRe: same enumeration, different results? Pin
CCodeNewbie20-Mar-12 2:21
CCodeNewbie20-Mar-12 2:21 
QuestionQuery an Excel Spreadsheet Pin
PDTUM19-Mar-12 6:35
PDTUM19-Mar-12 6:35 
AnswerRe: Query an Excel Spreadsheet Pin
PIEBALDconsult19-Mar-12 8:26
mvePIEBALDconsult19-Mar-12 8:26 
GeneralRe: Query an Excel Spreadsheet Pin
PDTUM19-Mar-12 8:47
PDTUM19-Mar-12 8:47 
GeneralRe: Query an Excel Spreadsheet Pin
PIEBALDconsult19-Mar-12 12:04
mvePIEBALDconsult19-Mar-12 12:04 
AnswerRe: Query an Excel Spreadsheet Pin
Dave Kreskowiak19-Mar-12 9:10
mveDave Kreskowiak19-Mar-12 9:10 
GeneralRe: Query an Excel Spreadsheet Pin
PDTUM19-Mar-12 11:08
PDTUM19-Mar-12 11:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.