Solved

source code to implement limited time feature on a software

Posted on 1998-11-19
2
180 Views
Last Modified: 2010-04-15
Can anybody tell me the source code to add the limited time
feature to a software?
0
Comment
Question by:SHAHZAD
2 Comments
 
LVL 4

Expert Comment

by:emmons
Comment Utility
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
 

Accepted Solution

by:
masche earned 50 total points
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
memory leak detection 9 51
Convert image to byte array 8 173
Handling string inputs in C/Linux 23 167
Passing command line arguments in C 10 80
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now