CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: SetSystemTime

  1. #1
    Join Date
    Aug 2001
    Posts
    11

    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)

  2. #2
    Join Date
    Jun 2001
    Posts
    1

    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);


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured