Im sure everyone has downloaded shareware programs that are 30 day free trials before you have to purchase the actual program. What I want to know is how they work?

How does the program know that 30 days is up? second, even after uninstalling the program and reinstalling it, it still remembers that the 30 day free trial is up. How does this work? is it storing some kind of "record keeping" file in a secret place on your computer that doesnt get removed when you uninstal the program?

I would like to know how they work becuase:
a) I want to make programs of my own that have a 30 day free trial function
b) I have a trial program that I would like to "reset" the computers memory that it has already been 30 days, so I can use it over and over without having to purchase the commercial one.