[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Set System Time

Could anyone please tell me how to set only the system Time? I've been all over the internet and everything I've found has just confused me. Is there an easy way to set the system Time? Please respond as soon as possible, thanks!
0
swhitlow
Asked:
swhitlow
1 Solution
 
rwilson032697Commented:
How about this?

//******************************************************************************
//Public function SetPCSystemTime changes the system date and time.
//Parameter(s): tDati  The new date and time//Returns:      True if successful
//              False if not
//******************************************************************************
function SetPCSystemTime(tDati: TDateTime): Boolean;
var  
  tSetDati: TDateTime;
  vDatiBias: Variant;  
  tTZI: TTimeZoneInformation;  
  tST: TSystemTime;

begin
   GetTimeZoneInformation(tTZI);  
   vDatiBias := tTZI.Bias / 1440;
   tSetDati := tDati + vDatiBias;      
   with tST do  
      begin
        wYear := StrToInt(FormatDateTime('yyyy', tSetDati));
        wMonth := StrToInt(FormatDateTime('mm', tSetDati));
        wDay := StrToInt(FormatDateTime('dd', tSetDati));
        wHour := StrToInt(FormatDateTime('hh', tSetDati));
        wMinute := StrToInt(FormatDateTime('nn', tSetDati));
        wSecond := StrToInt(FormatDateTime('ss', tSetDati));
        wMilliseconds := 0;  
     end;
   SetPCSystemTime := SetSystemTime(tST);
end;

Cheers,

Raymond.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now