The software simply needs to persist a number somewhere it can find it again, and increment it every time it runs. Of course, if this is on the local machine, the user can find it and reset it, and if you keep it on a remote machine, you've got a huge amount of management to do to keep track of who is using what. And it still won't be infallible
In short, there is no foolproof way to do this. An alternative is to give away a feature-limited version that does not do everything your real app does, but does enough that people can see if its useful to them or not. Finding the right balance between it being useful enough to get people to want it but being restricted enough that they'll want to buy the full version, is the tricky bit