Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

Booting Date and Time

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
Munim
Asked:
Munim
1 Solution
 
fb132Commented:
procedure bla()
var
dates := String;
hours := String;
begin

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

end;
0
 
Russell LibbySoftware Engineer, Advisory Commented:

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
 
MunimAuthor Commented:
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
 
NetminderCommented:
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

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now