Solved

Set new sysdate from delphi 2.0, 3.0

Posted on 1998-01-14
8
427 Views
Last Modified: 2010-04-04
I need a procedure that can change the system date and time

I use both win95 and NT
0
Comment
Question by:lpd
  • 3
  • 3
  • 2
8 Comments
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
Are you using NT or 95?
0
 

Author Comment

by:lpd
Comment Utility
Edited text of question
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 50 total points
Comment Utility
Use the SetSystemTime api call.

E.g.  To set time to 20 May 1998, 10:30 a.m.

procedure SetNewSystemTime;
var
  SysTime: TSystemTime;
begin
  FillChar(SysTime, SizeOf(TSystemTime), 0);
  SysTime.wYear := 1998;
  SysTime.wMonth := 5;
  SysTime.wDay := 20;
  SysTime.wHour := 8;
  SysTime.wMinute := 30;
  SetSystemTime(SysTime);
end;


Note:  The hour will be 2 more than you specify on Win 95.  (NT???)

JB
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
Thank you

it works fine but, a have a small problem with timezones. the procedure that you wrote will set the time as if the timezone was GMT. Do you know how to see that timezone that currently is in use ?

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:lpd
Comment Utility
Ah, that would explain why I need to -2 for hour!!

To get current timezone bias, use GetTimeZoneInformation.

E.g.
var
  MinutesDiff: Integer;
  TZInfo: TTimeZoneInformation;
begin
  GetTimeZoneInformation(TZInfo);
  MinutesDiff := TZInfo.Bias;
end;

In my case, MinutesDiff = -120 (i.e. 2 hrs behind).

JB
0
 
LVL 5

Expert Comment

by:JimBob091197
Comment Utility
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
P.S.  If you don't want do the TimeZone thing, use SetLocalTime instead of SetSystemTime.

JB
0
 
LVL 5

Expert Comment

by:JimBob091197
Comment Utility
Thanks agin
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now