Solved

source code to implement limited time feature on a software

Posted on 1998-11-19
2
181 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
ID: 1254478
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
ID: 1254479
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers 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.

863 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

26 Experts available now in Live!

Get 1:1 Help Now