Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <fstream>
- #include <vector>
- using namespace std;
- void ReadTimeValues(vector<long>& vec)
- {
- FILE* f = fopen("time.txt", "r");
- if(f)
- {
- long date;
- while(feof(f))
- {
- fscanf (f, "%d\n", &date);
- vec.push_back(date);
- }
- fclose(f);
- }
- }
- void SaveDate(long date)
- {
- FILE* f = fopen("time.txt", "a+");
- fprintf(f, "%d", date);
- fclose(f);
- }
- int main()
- {
- SYSTEMTIME lt;
- GetLocalTime(<);
- long currentDate = lt.wYear * 10000 + lt.wMonth*100 + lt.wDay;
- vector<long> timeVector;
- ReadTimeValues(timeVector);
- bool dateFound = false;
- for(size_t i = 0; i < timeVector.size(); ++i)
- {
- if ( currentDate == timeVector[i] )
- dateFound = true;
- }
- if(!dateFound)
- {
- //aici faci apelurile catre functia system(...)
- //in loc de .bat file
- SaveDate(currentDate);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment