C# Application self-destroy at specific date
Is there anyway 开发者_C百科I can use to destroy my deployed application at specific date?. How can I order the application to destroy itself at specific date after installation?. Say I deployed my C# application at PC1 today. After a specific date the application is deleted and removed off PC1 automatically (Installation folder removed). How can I do that?. If this is not possible, at least how can I prevent the user from using it anymore after specific date?.
Probably the easiest way would be to securely encrypt the expiry date and store it to a config file (or registry). On startup decrypt the expiry date and check against current date. If you wanted to tamper proof it you could also encrypt the date/time the application was first installed, or last ran (to check that the date/time isn't being fiddled, such as being manually adjusted prior to launching the application)
Automatically uninstalling is a tremendously bad idea though. I'd settle with just displaying a warning that the application has expired.
You need to think very carefully about what you want to implement here - you are opening up a can of worms if you make changes to the user's system that the user has not permitted.
By all means make your app refuse to function (i.e. cripple it), but do not have it self destruct.
http://msdn.microsoft.com/en-us/library/system.componentmodel.license(VS.71).aspx
Try starting there. I'm sure you could set up a license that held date expiry information, and therefore you could prevent the app from continuing in the event that the expiry date has passed.
精彩评论