Link to home
Start Free TrialLog in
Avatar of rcastle
rcastle

asked on

Set System Time NT

Does someone have an easy reliable way of setting system time in NT and Win95 including AdjustTokenPrivileges in NT.  I'm just not getting it.

Thanks
Avatar of Greedy
Greedy

Yeah I saw it...now to find it...the artile tile had time, nt and ID in it...found a 95 one...I'll keep looking for the NT one...

Setting time system with Delphi
abeldup@unison.co.za (Abel du Plessis)

"Vitor Martins" <nop47019@mail.telecom.pt wrote:


How can I set the clock system time and date in a program  with Delphi 2.0
in Win 95
This works for us:


--------------------------------------------------------------------------------

//******************************************************************************
//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;

--------------------------------------------------------------------------------

ASKER CERTIFIED SOLUTION
Avatar of Greedy
Greedy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rcastle

ASKER

Thanks Greedy, doubling points for complete answer pointing out my stupidity and pointing me back at chami which I should have checked.
No prob man...thanks