laitimes

In software development, the development and implementation process of setting the running time of the stand-alone version of the software is implemented, including code

Restricting the runtime of the software means that the software can be automatically shut down after it has been started and can only be performed for a specified period of time before the software has been registered as an official version. Authors can set it up according to their own needs.

To implement the timing function, you can use the Timer control to implement, the general control time interval is 1s (1000ms), according to the actual needs to set the expected value.

The implementation process of limiting the runtime of the software through the Timer control is as follows:

Set the time interval of the Timer control, taking 5 minutes as an example. Then the value of Interval is 1000*60*5=300000,

Execute the Timer control when the software starts. When the use time is full for 5 minutes, the software will automatically shut down.

The complete sample code that limits the runtime of the software is as follows:

Limiting software runtime can also be implemented using API functions, such as SetTimer and KillTimer, and the function prototypes in MSDN are as follows:

Implementing a timer with api is to first use the SetTimer function to apply for a timer from the system, then call the callback function when dealing with the timeout, and finally use KillTimer to destroy the timer.

The prototype of the callback function that times out the call is as follows:

The sample code for setting the software runtime using the API implementation is as follows:

Read on