Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

source code to implement limited time feature on a software

Can anybody tell me the source code to add the limited time
feature to a software?
0
SHAHZAD
Asked:
SHAHZAD
1 Solution
 
emmonsCommented:
There are lots of ways to do it.
If you are in Windows, you could add a date to the registry or config file, and compare against that (more robustly, you could encrypt the date before saving it)
You could create a data file for your program on install (or on first run) and then compare against that date. This is a little more portable, but it involves asking the OS for the date stamp on a file and comparing it against the current date. Or put the date in the file.
0
 
mascheCommented:
here is a simple solution of mine:

{
        struct tm *newtime;
        time_t long_time;

        time( &long_time );                /* Get time as long integer. */
        newtime = localtime( &long_time ); /* Convert to local time. */

        if( newtime->tm_year >= 98 )       {
      if( newtime->tm_mon >= 12  )   {
             AfxMessageBox ( "Program has timed out !!!") ;
            timedOut= 1 ;
      }
        }
        if ( !timedOut)       {              // let's check the file PAGEFILE.SYS
                                                          // for those who changed their clock...
      char *FileName = "C:\\PAGEFILE.SYS" ;
       time_t now= time(NULL) ;

      for ( int i=0 ; i<10 ; ++i )     {
           int result;
           struct _stat buf;
           result = _stat( FileName, &buf );
        /* Check if statistics are valid: */
           if( result == 0 )      {
            if ( (now< buf.st_ctime )  )   {
            AfxMessageBox ("You changed your clock! Program ist timed out!!!") ;
            timedOut;
            break ;
               }
      }
      ++FileName[0] ;              // c: / d: / e:...
      }
      }
}

I hope this helped!

Harald
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now