T0masz
asked on
date change
Hey,
I have a little problem with my program, it should change the date to (somedate) run a program, wait 5s and change it back.
Tom
--snip--
procedure TForm1.FormCreate(Sender: TObject);
var
myDate,newDate : TDateTime;
myYear, myMonth, myDay : Word;
begin
DecodeDate(myDate, myYear, myMonth, myDay);
myDate := StrToDate('04/24/2003');
WinExec('c:\bin\date', SW_SHOWNORMAL);
Sleep(5000);
newDate := EncodeDate(myYear, myMonth, myDay);
ReplaceDate(myDate, newDate);
//myDate := RecodeDate(myDate, myYear, myMonth, myDay);
Application.Terminate;
end;
I have a little problem with my program, it should change the date to (somedate) run a program, wait 5s and change it back.
Tom
--snip--
procedure TForm1.FormCreate(Sender: TObject);
var
myDate,newDate : TDateTime;
myYear, myMonth, myDay : Word;
begin
DecodeDate(myDate, myYear, myMonth, myDay);
myDate := StrToDate('04/24/2003');
WinExec('c:\bin\date', SW_SHOWNORMAL);
Sleep(5000);
newDate := EncodeDate(myYear, myMonth, myDay);
ReplaceDate(myDate, newDate);
//myDate := RecodeDate(myDate, myYear, myMonth, myDay);
Application.Terminate;
end;
use can use also this function to convert TDateTime to TSystemTime and back
function SystemTimeToDateTime(const
procedure DateTimeToSystemTime(DateT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to all of you, but rllibby was the closest one, plus I really dont like using TSystemTime because you have to put all the parameters date,time so on and on one station it didnt work correctly for some reason.
Tom
Tom
You do not replace the system date ...
use the API SetLocalTime
example :
procedure TForm1.Button1Click(Sender
var
SysTime : TSystemTime;
begin
with SysTime do
begin
wYear := 2004;
wMonth := 4;
wDayOfWeek := 3;
wDay := 4;
wHour := 20;
wMinute := 51;
wSecond := 0;
wMilliseconds := 0;
end;
SetLocalTime(SysTime);
end;