?
Solved

Booting Date and Time

Posted on 2003-02-26
4
Medium Priority
?
188 Views
Last Modified: 2010-04-04
Hello Experts,
   I would like to know, how to retrive the date and time of when this computer started. I can figure out how many days, hours, minutes, seconds passed after computer has started by using the API GetTickCount... But the fact is, how can I figure out the date and time when this computer turned on...

Thank You
0
Comment
Question by:Munim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Expert Comment

by:fb132
ID: 8026174
procedure bla()
var
dates := String;
hours := String;
begin

dates := dateToStr(Now);
hours := timeToStr(Now);

end;
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 40 total points
ID: 8026197

Given the fact that GetTickCount returns the number of MS since startup, all that needs to be done is to divide GetTickCount by the number of ms in a day, then subtract this from today.

var  dwStarted:  LongWord;
     dblStarted: Double;
begin

  // Get count of ms running
  dwStarted:=GetTickCount;

  // Convert it into double (TDateTime) and subtract from now
  dblStarted:=(Now - (dwStarted / MSecsPerDay));

  // Show the date and time system was started
  ShowMessage(FormatDateTime('dddd, mmmm d, yyyy, hh:mm AM/PM', dblStarted));

end;

Please note that due to the storage type used for GetTickCount (4 bytes), the number will "wrap" after 49.7 days. On WinNT/2000 and greater, you could also query the System Up Time counter in the performance data in the registry key HKEY_PERFORMANCE_DATA.

Hope this helps,
Russell




0
 
LVL 1

Author Comment

by:Munim
ID: 8043030
I would have rated your code Excellent, if you've provided me, NON-VCL solution... But still, I've done it in the way to do it... (NON-VCL)...

Thank You

Munim
0
 
LVL 5

Expert Comment

by:Netminder
ID: 8046547
Munim,

If the coding provided works, why did you grade a C?

Grading at Experts Exchange isn't like grading in school. It's a lot closer to the way the US Department of Agriculture grades meat; everything is Prime unless it isn't, in which case it's Choice or Select.

You should always give an A unless you have a good reason to grade less. For example, if you asked for more information and you didn't get it, or the expert only gave you a starting point and you still had to do most of the grunge work yourself, then a B is acceptable

A C grade is particularly unacceptable if the person simply posted their suggestion as a comment. After all, you are not obliged to accept a comment as the answer. You should always give an Expert a chance to raise a grade before giving a C.

Another thing you might want to consider is that a lot of our top experts check an asker's grading record. If they see that an asker habitually grades questions with "B"s or even "C"s they would be very reluctant to give their help. With your current record, you might find it difficult to get good and timely answers.

Netminder
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question