Cookies are for web pages and web browsers. But regardless, wherever you store the data, it can be deleted, or your program can be patched to ignore that data by pirates.
For example, you can open a file, read the counter, increment by one and write that value back. Other people can alter the value too, so you need to find a way around that.
Or you could just use a ready-made licensing solution.
Bookmarks