-
SetSystemTime
I'm trying to set the system time.
SCENERIO:
Through Socket, Server sends it current FILETIME to client. Client gets the SYSTEMTIME from the sent time and then call SetSystemTime() using this system time. But the set time is differnt by +/- GMT TIME DIFFERENCE ('coz of the TIME_ZONE). Can somebody suggest how to make it work. (I've tried but could'nt handle Getting Timezoneinfo and Setting timezone info)
Best Wishes
Asim Hussnain
(Intech)
-
Re: SetSystemTime
Hi
Here is a code that work in our system.
lJulianTime - long number that hold the julian seconds.
TIME_ZONE_INFORMATION lp;
GetTimeZoneInformation(&lp);
long l = (lJulianTime / 60 + lp.Bias) * 60;
CTime CurrentTime(l);
SYSTEMTIME* SystemTime = new SYSTEMTIME();
SystemTime->wDay = CurrentTime.GetDay();
SystemTime->wDayOfWeek = CurrentTime.GetDayOfWeek();
SystemTime->wHour = CurrentTime.GetHour();
SystemTime->wMilliseconds = 0;
SystemTime->wMinute = CurrentTime.GetMinute();
SystemTime->wMonth = CurrentTime.GetMonth();
SystemTime->wSecond = CurrentTime.GetSecond();
SystemTime->wYear = CurrentTime.GetYear();
BOOL B = SetSystemTime (SystemTime);