Recent

Author Topic: Set system time WinCE  (Read 4697 times)

ertank

  • Full Member
  • ***
  • Posts: 244
Set system time WinCE
« on: April 23, 2016, 09:32:59 am »
Is there any code sample for changing WinCE system date time? I couldn't find an post in the forum.

Thaddy

  • Hero Member
  • *****
  • Posts: 8680
« Last Edit: April 23, 2016, 10:38:46 am by Thaddy »
Most people that want to use threading should learn to patch their jeans first: use a needle.

ertank

  • Full Member
  • ***
  • Posts: 244
Re: Set system time WinCE
« Reply #2 on: April 26, 2016, 09:05:36 pm »
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

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

ertank

  • Full Member
  • ***
  • Posts: 244
Re: Set system time WinCE
« Reply #3 on: April 26, 2016, 09:19:35 pm »
Ok, Seems like I need to add "Windows" unit in uses clause. Below code works fine for me

Code: [Select]
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;