Solved

Set new sysdate from delphi 2.0, 3.0

Posted on 1998-01-14
8
434 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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
 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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