FROM : Power Mac User
DATE : Fri Apr 08 21:16:53 2005
On Apr 8, 2005, at 11:16 AM, <email_removed> wrote:
> Hello out there,
>
> Does anybody know, how to deactivate a software after a certain
> test/trial period, so that after this time the apllication won't
> launch anymore?
>
> Could someone support me with source-code (for cocoa/obj.C) for this
> issue.
>
> Thanks in advance!!!!
>
> DH
>
Hello!
Perhaps you can use NSUserDefaults.
#define YOUREXPIRATIONPERIOD // NSTimeInterval which is a double
+ (void)initialize
{
NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary];
[defaultValues setObject:[NSDate date] forKey:@"AppInstallationDate"];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
}
Then in your NSApp delegate's applicationWillFinishLaunching:
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
NSDate *installDate = [[NSUserDefaults standardUserDefaults]
objectForKey:@"AppInstallationDate"];
if ( [[install date] timeIntervalSinceNow] > YOUREXPIRATIONPERIOD )
{
// Possibly insert a NSAlert
[NSApp terminate:nil]
}
}
Regards,
<email_removed>
DATE : Fri Apr 08 21:16:53 2005
On Apr 8, 2005, at 11:16 AM, <email_removed> wrote:
> Hello out there,
>
> Does anybody know, how to deactivate a software after a certain
> test/trial period, so that after this time the apllication won't
> launch anymore?
>
> Could someone support me with source-code (for cocoa/obj.C) for this
> issue.
>
> Thanks in advance!!!!
>
> DH
>
Hello!
Perhaps you can use NSUserDefaults.
#define YOUREXPIRATIONPERIOD // NSTimeInterval which is a double
+ (void)initialize
{
NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary];
[defaultValues setObject:[NSDate date] forKey:@"AppInstallationDate"];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
}
Then in your NSApp delegate's applicationWillFinishLaunching:
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
NSDate *installDate = [[NSUserDefaults standardUserDefaults]
objectForKey:@"AppInstallationDate"];
if ( [[install date] timeIntervalSinceNow] > YOUREXPIRATIONPERIOD )
{
// Possibly insert a NSAlert
[NSApp terminate:nil]
}
}
Regards,
<email_removed>
| Related mails | Author | Date |
|---|---|---|
| Power Mac User | Apr 8, 21:16 | |
| John Brownlow | Apr 8, 21:24 | |
| Lon Varscsak | Apr 8, 21:31 |






Cocoa mail archive

