Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how do i change the date or time?

mydelphimydelphi Member Posts: 62
Please put me out of my misery. I don't get it, how do I change the date on my computer
like I can in dos?

I only need to change the date, not the time. Every time I change the date, the time is
changed. But the code seems to require the time fields to be entered in order to work and
that seem a bit unfair. There must be a better way!

In dos, at the c: you change eitehr one, date or time:

date: 1/1/2000 --- a new year
time: 8:30am ----- time to go to work!

Anyway, after google searching around I found some code snips that showed an example.
I couldn't belive how much code it requires just to change one thing!! But, here is the
code, though I did a lot of changing it around and reworking it for my own tests. But this
routine changes my time to 5:00pm every time, even though I only want to change the date!

If someone can show me an easy one-liner, I would be very greatful. I will be using the code
for both my windows xp and older windows 98se computers.

Thanks,
mydelphi

[code]procedure TForm1.Button1Click(Sender: TObject);
var
ADate, ATime : TDateTime;
begin
// convert string to date..
adate := strTodate(eb3.text);
atime := strToTime(eb4.text);

FillChar (MyTime, sizeof(MyTime), #1);
DateTimeToSystemTime(adate,mytime);

inc(mytime.wDay);
setSystemTime(mytime);

// if not SetSystemTime (MyTime) then ShowMessage ('Failure!');
end;[/code]
Sign In or Register to comment.