Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips

#53: How can I set a clock (system datetime) in MS Windows?

If you need set the system date and time in MS Windows from your application, then you can use the next code:

function ChangeSystemDateTime(dtNeeded: TDateTime): Boolean;
  tzi: TTimeZoneInformation;
  dtSystem: TSystemTime;
  dtNeeded := dtNeeded + tzi.Bias / 1440;
  with dtSystem do
    wYear := StrToInt(FormatDateTime('yyyy', dtNeeded));
    wMonth := StrToInt(FormatDateTime('mm', dtNeeded));
    wDay := StrToInt(FormatDateTime('dd', dtNeeded));
    wHour := StrToInt(FormatDateTime('hh', dtNeeded));
    wMinute := StrToInt(FormatDateTime('nn', dtNeeded));
    wSecond := StrToInt(FormatDateTime('ss', dtNeeded));
    wMilliseconds := 0;
  Result := SetSystemTime(dtSystem);

Published: December 10, 1999

See also
Paradox Password Recovery
Paradox Viewer
SMImport suite
Mail parser (ActiveX)
SMExport suite
Viewer for MS Outlook Messages
Word Web-stream
Paradox ActiveX
Excel Web-stream
ABA Spreadsheet Convert

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2022, Scalabium Software. All rights reserved.

SMExport/SMImport suites