SetSystemTime(SYSTEMTIME &st)

解决方案 »

  1.   

    typedef struct _SYSTEMTIME { 
        WORD wYear; 
        WORD wMonth; 
        WORD wDayOfWeek; 
        WORD wDay; 
        WORD wHour; 
        WORD wMinute; 
        WORD wSecond; 
        WORD wMilliseconds; 
    } SYSTEMTIME, *PSYSTEMTIME; BOOL SetSystemTime(
      CONST SYSTEMTIME *lpSystemTime   // system time
    );
      

  2.   

    Setting the System Time
    The following example sets the system time using the SetSystemTime function.// SetNewTime - sets system time
    // Return value - TRUE if successful, FALSE otherwise
    // hour     - new hour (0-23)
    // minutes  - new minutes (0-59)BOOL SetNewTime(WORD hour, WORD minutes)
    {
        SYSTEMTIME st;
        char *pc;    GetSystemTime(&st);       // gets current time
        st.wHour = hour;          // adjusts hours 
        st.wMinute = minutes;     // and minutes
        if (!SetSystemTime(&st))  // sets system time
            return FALSE;
        return TRUE;
    }