Solved

Set new sysdate from delphi 2.0, 3.0

Posted on 1998-01-14
8
428 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
ID: 1356482
Are you using NT or 95?
0
 

Author Comment

by:lpd
ID: 1356483
Edited text of question
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 50 total points
ID: 1356484
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
ID: 1356485
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:lpd
ID: 1356486
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
ID: 1356487
0
 
LVL 5

Expert Comment

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

JB
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1356489
Thanks agin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filemaker 14 vs Delphi Embarcadero 7 185
Syntax Check Delphi Seattle IOS app without MAC ? 1 91
code issue 8 99
Process Javascript errors with Delphi TWebBrowser 1 111
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

919 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

18 Experts available now in Live!

Get 1:1 Help Now