Click to Rate and Give Feedback
MSDN
MSDN Library
Setting the System Time

The following example sets the system time using the SetSystemTime function.

#include <windows.h>

// SetNewTime - sets system time
//
// Parameters
//    hour     - new hour (0-23)
//    minutes  - new minutes (0-59)
//
// Return value - TRUE if successful, FALSE otherwise

BOOL SetNewTime(WORD hour, WORD minutes)
{
    SYSTEMTIME st;

    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;
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker