On Windows (as you seem to be using this OS) you can do something like this:
#include <windows.h> #include <stdio.h> /* The date on which this program should continue running */ #define DAY 10 #define MONTH 12 /* 1 = Jan... 12 = Dec */ int main() { SYSTEMTIME t; GetLocalTime(&t); if (t.wDay != DAY || t.wMonth != MONTH) { printf("You can't open this program today!\n"); MessageBox(0, "You can't open this program today!", "Error", MB_ICONSTOP); return 1; } system("start https://www.youtube.com/watch?v=FchMuPQOBwA"); return 0; }
The GetLocalTime () and SYSTEMTIME functions are located in windows.h, which you need to enable.
Or alternatively use the function time () from time.h, but in this case you need to convert the desired day to a UNIX timestamp (see http://en.wikipedia.org/wiki/Unix_time ) or convert the information returned by time () per day / month.
It was a simple program that would only run on that particular day, and exit with an error message if not. If you want to make a program that is installed on his computer when he launches it, and then waits for a certain time before opening a web page, this is much more complicated (you basically need to copy the EXE file somewhere on the system and add it to the registry, so that it starts automatically when you log in ... maybe no more than 30 lines of code, but not the easiest :-)).
To send it as an EXE so that it does not see the source code, you just need to compile it as if you were running it, and then send the EXE to it (make sure it does not require a runtime library from the compiler, check on another computer if it works correctly). Of course, if your dad looks into an EXE file with some kind of editor, he will see the address of the web page (but not easily, what is the condition that opens this page).
source share