Forum > Windows CE

Set system time WinCE

(1/1)

ertank:
Is there any code sample for changing WinCE system date time? I couldn't find an post in the forum.

Thaddy:
http://www.festra.com/eng/snip07.htm
Works also for wince.

As does this:
http://www.delphitricks.com/source-code/windows/change_the_system_time.html

ertank:

--- Quote from: Thaddy on April 23, 2016, 10:37:15 am ---http://www.festra.com/eng/snip07.htm
Works also for wince.

As does this:
http://www.delphitricks.com/source-code/windows/change_the_system_time.html

--- End quote ---

Above links, I do not know which unit to import for "SetLocalTime". It is not known and compiler throws an error.

ertank:
Ok, Seems like I need to add "Windows" unit in uses clause. Below code works fine for me


--- Code: ---uses Windows;

procedure TForm1.Button3Click(Sender: TObject);
var
  dt:TSystemTime;
begin
  dt.wYear := StrToInt(FormatDateTime('yyyy', now));
  dt.wMonth := StrToInt(FormatDateTime('mm', now));
  dt.wDay := StrToInt(FormatDateTime('dd', now));
  dt.wHour := StrToInt(Edit1.Text);
  dt.wMinute := StrToInt(Edit2.Text);
  dt.wSecond := StrToInt(Edit3.Text);
  dt.wMilliseconds := 0;
  SetLocalTime(dt);
end;

--- End code ---

Navigation

[0] Message Index

Go to full version