Recent

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

ertank

  • Sr. Member
  • ****
  • Posts: 274
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: 14201
  • Probably until I exterminate Putin.
« Last Edit: April 23, 2016, 10:38:46 am by Thaddy »
Specialize a type, not a var.

ertank

  • Sr. Member
  • ****
  • Posts: 274
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

  • Sr. Member
  • ****
  • Posts: 274
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;

 

TinyPortal © 2005-2018