Question: I want code to find last day of the month. I want to make calendar.
Question:
Delphi give use native function for this.
Check this.
uses SysUtils, DateUtils;
function getLastDay : TDateTime;
begin
result := EncodeDate(YearOf(Now), MonthOf(Now), MonthDays[IsLeapYear(YearOf(Now)), MonthOf(Now)]);
end;
Question:
I want to change System time from my application immediatelly.
Do you have the code?
Answer:
Sure,
The input strings for date and time depends on the format you are using.
procedure TForm1.Button1Click(Sender: TObject);
var
SystemTime: TSystemTime;
NewTime, NewDate: string;
begin
NewTime := '12:00:00';
NewDate := '01.01.2006';
DateTimeToSystemTime(StrToDate(NewDate) + StrToTime(NewTime), SystemTime);
SetLocalTime(SystemTime);
// Tell windows, that the Time changed!
PostMessage(HWND_BROADCAST, WM_TIMECHANGE, 0, 0); // *
end;