tags:

views:

70

answers:

3

Now in my country the local time is:

3:43 PM   

Can I write program in C++ to change the time on a Windows 7 system to another time?

For example set it to 5:00 PM (increase) or decrease it?

+3  A: 

The answer to this question depends on your operating system.

However doing this in C++ seems pointless. If you really want to this programmatically It may be easier to write a shell/batch script.

Ugo
+1 for "operating system dependent".
Dacav
+2  A: 
#include Windows.h

BOOL WINAPI SetSystemTime(const SYSTEMTIME *lpSystemTime);
Lior Kogan
+3  A: 

In VC++ you can try. Include the Windows.h header file.

SetSystemTime Function

SYSTEMTIME st;
st.wYear = 2010;
st.wMonth = 5;
st.wDay = 2;
st.wHour = 7;
st.wMinute = 46;
st.wSecond = 31;
st.wMilliseconds = 345;
::SetSystemTime(&st);
DumbCoder