Here is the easiest way to perform operations that are based on some specific future time:
First, you'll need to include the windows.h library:
Code:
#include<windows.h>
SYSTEMTIME is a structure containing the following attributes:
Code:
typedef struct _SYSTEMTIME
{
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
}SYSTEMTIME, *PSYSTEMTIME;
Using the SYSTEMTIME structure, it is really easy to get any information we want as far as the current time. The month is 1-based (that is, January is 1), and the day of the week is 0-based (Sunday is 0). The wDay field is the current day of the month, which is also 1-based.
Now declare an object of type SYSTEMTIME:
GetLocalTime() will populate the SYSTEMTIME struct with the most current local date and time directly from the user's computer. It accepts a single argument:
Also, we have GetSystemTime()... similar to GetLocalTime, but will populate the SYSTEMTIME struct with the current UTC time and date.
Code:
GetSystemTime(&st);
At this point, you know how to obtain the current time and date. This might be enough for what you are looking to do. You can simply compare current time and date to that of a specific point in the future, and then perform an action when they are equal. An alternative method would be to set a timer and perform an action when the timer expires, but setting a timer would require a background in windows programming.. having your program respond to WM_TIMER messages that would be send to your program by windows at a predetermined intervals.