RE: Where to store application expiration date in a trial app
- From: Peter Bromberg [C# MVP] <pbromberg@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 10 Jun 2006 17:22:01 -0700
You say "Such as the Registry" making the assumption that it is a "secure
place". It is not. Anybody can use Regedit to search and modify the registry
on their own machine. Isolated storage would probably be a potential choice.
You have methods in .NET framework to access this. DPAPI is another choice,
including encryption.
If you are looking for a commercial solution, there are a number of them
available. I'd start my search at some place like ComponentSource.com.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Mike9900" wrote:
I wanted a secure place such as registry to store the date/time expiration of.
the software. For example, if the software expires in 30 days, each day the
user starts the program it increments the date and stores that date in a
file, it may encrypt it as well. So where is the most secure place to store
that file, also the user must have access right to that place.
Is there a better way for licensing software, or is there a good component I
can buy?
--
Mike
"Peter Bromberg [C# MVP]" wrote:
Mike,
here is a "greatly simplified" example of how you could do this. Be aware,
this is NOT SECURE from decompilation!:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Reflection ;
[assembly: AssemblyConfiguration("06/10/2006")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AssemblyConfigurationTest
{
public class WebForm1 : System.Web.UI.Page
{
DateTime ExpirationDate;
private void Page_Load(object sender, System.EventArgs e)
{
Assembly asm = Assembly.GetExecutingAssembly();
int asmHash = asm.FullName.GetHashCode();
object[] objArray=asm.GetCustomAttributes(false) ;
int hash ;
foreach (object obj in objArray)
{
AssemblyConfigurationAttribute conf =
obj as AssemblyConfigurationAttribute;
if (conf != null)
{
hash = conf.Configuration.GetHashCode();
if(hash !=-579392602 || asmHash!=-258347722)
throw new InvalidOperationException("Assembly Has been Altered! Bad,
Bad!");
this.ExpirationDate=Convert.ToDateTime(conf.Configuration) ;
}
}
Response.Write("This Trial Version Expires: "
+this.ExpirationDate.ToString());
}
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Mike9900" wrote:
Hello,
I would like to store application expiration date in a file and store that
file in a secure place, so the application can access the file for all the
users on that computer.
IsolatedStorage is a good technique but it is for the each user only and is
not machine level. Registry is not good because the user may not have access
permission. Application directory is not good because the file could be
deleted and so the application trial mode does not work. So what directory
is good or does windows has an API to store a file or data?
--
Mike
- References:
- RE: Where to store application expiration date in a trial app
- From: Peter Bromberg [C# MVP]
- RE: Where to store application expiration date in a trial app
- From: Mike9900
- RE: Where to store application expiration date in a trial app
- Prev by Date: RE: Strategic Functional Migration and Multiple Inheritance
- Next by Date: Re: Simple (hopefully) form question
- Previous by thread: RE: Where to store application expiration date in a trial app
- Next by thread: Flash SWF in Windows Forms
- Index(es):
Relevant Pages
|