• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

How can I change system Date/time !!

It is very easy question.
What is the Delphi procedures which set date and time ?

Motaz
0
Motaz
Asked:
Motaz
  • 3
1 Solution
 
scrapdogCommented:
You axed it twice, I'll answer it twice!!


Here is the data structure:

TSystemTime = record
    wYear: Word;
    wMonth: Word;
    wDayOfWeek: Word;
    wDay: Word;
    wHour: Word;
    wMinute: Word;
    wSecond: Word;
    wMilliseconds: Word;
  end;


Set the date time like this:

var
  NewTime :TSystemTime;

NewTime.wYear := 1998;   ,etc, etc.

Then you call the function SetSystemTime

SetSystemTime(NewTime);


If you only wanted to change one part of the system time, you could call GetSystemTime

GetSystemTime(NewTime);
NewTime.wYear := 1999;
SetSystemTime(NewTime);


The SetSystemTime function returns a boolean, indicating whether it succeeded or not.  

OK := SetSystemTime(NewTime);
if not OK then ShowMessage('Time not set');




Make sure that Windows is in your uses clause if you use any of these functions.
0
 
MotazAuthor Commented:
Thanks Scrap, But I don't ask this question befor ??  :)

Motaz
0
 
MotazAuthor Commented:
Thanks Scrap, But I don't ask this question befor ??  :)

Motaz
0
 
MotazAuthor Commented:
Oh !!. How did you do that ? ( Answering twice ???? )
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now