hello ,
today i suddenly think about creating an application that has limited uses . i mean after using an application for 30 days , it should not start the application . How can i do that ?

i can decide if the day is the last day or not(i mean using some date comparision functions i can decide if the day is 30th day) but then after how to code for trial expiration ?

it is database application ? if yes then store data in encrypted format and on load of you master form check the date. You can also write date value in windows registry. here is the link Click Here . you can also save the date value in .ini file after encryption.

I'd probably go with a simple licensing mechanism:

using System;
using System.Globalization;

namespace BasicLicense
{
    public class License
    {
        public string ProductCode { get; set; }
        public DateTime ExpiresOn { get; set; }
        public bool IsValid { get; set; }

        public License(string licenseCode, string productCode, string registeredTo)
        {
            ExtractLicense(licenseCode, productCode, registeredTo);
        }

        private void ExtractLicense(string licenseCode, string productCode, string registeredTo)
        {
            IsValid = false;

            try
            {
                string licenseData;

                using (var crypto = new Decryption(registeredTo, "ALLPURPOSELICENSE"))
                {
                    licenseData = crypto.Decrypt(licenseCode);
                }

                var parts = licenseData.Split('|');

                // License format: PRODUCT_CODE|EXPIRES_ON|"LIC"
                if (parts.Length == 3 && parts[2] == "LIC")
                {
                    ProductCode = parts[0];
                    ExpiresOn = DateTime.ParseExact(parts[1], "yymmdd", null, DateTimeStyles.None);

                    if (ProductCode == productCode && ExpiresOn >= DateTime.Today)
                    {
                        IsValid = true;
                    }
                }
            }
            catch
            {
                // Ignore the exception, the license is invalid
            }
        }
    }
}

By default the application would be installed with a demo license where the expiration date is set 30 days after the time of installation. Once the trial is converted to a permanent license, the expiration date can be set to DateTime.MaxValue. Easy peasy.

Edit: Whoops, thought this was the C# forum. I'm too lazy to convert the code, but it's relatively simple. ;)

    Public day As String
    Public month As String
    Public year As String

    day = My.Computer.Clock.LocalTime.Day
        month = My.Computer.Clock.LocalTime.Month
        year = My.Computer.Clock.LocalTime.Year
        If My.Settings.checked = False Then
            My.Settings.day = day
            My.Settings.month = month
            My.Settings.year = year
            My.Settings.checked = True
        Else
            If year = My.Settings.year Then
                If month = My.Settings.month Then
                Else
                    If month = My.Settings.month + 1 Then
                        If day = My.Settings.day Then
                            MsgBox("Trial is over")
                        Else
                            If day > My.Settings.day Then
                                MsgBox("Trial is over")
                            End If
                        End If
                    Else
                        If month <> My.Settings.month + 1 Then
                            MsgBox("Trial is over")

                        End If
                    End If
                End If
            Else
                MsgBox("Trial is over")
            End If

        End If


    End Sub
End Class

if you got the proper solution then please mark the thread as solved
Thank you - Deep Modi

the above code is not working . My IDE does not understand the statement at line 8.

Ok,
but I want say that the code is correct, the reason is that placing code in different place.
don't worry i will gave example program (this may take time, as i have to create it)

Can i know where you want to save the serial (activation) ?

I mean using registry or you want to save in program setting.

If you want to learn then you should use in program setting, or if you want to publish program then use registry like IDM,
reg/.../program name/activation
reason: You can do this with installer directly...

What the program:
if you are using trial program, then program will show date expired else
it will continue as trial

i am not much familiar with registry and therefore i think that going with program setting will be good enough for me to understand the code.

i want to create trial of an application which ask for activating the application upto 30 days . After 30 days application should not start. Or if user enters the correct serial number then it stop asking for serial number(it will be like activated version)

hope i explain in clear words.

ok, no problem dude

I will create the tutorial program on this for you

As you toldd that you are having the error on the line 8,
but it's all right,
nothing there something wrong, I do same thing, copy and paste.

Yes I create the setting:
day, momth, year as string
and checked as boolean and set the value as false...
→ here may your problem arise:
0133aa78c4b688be26aaf26ef40d6f27

nothing so...
and it working too

hey,
Check the full prohect here:
Remember i add the seril activation, and the serial is: 1234-5678-90

If trial is over,
the page with buy program will be active,
before starting the program buy or use trial form will be seen

and more and more.
(and please also feedback me)

Project File:

As My trial Form app inthe previous zip tell you how to create trial form.
But as we talk and as per their drawback in that procedure I attached here new procedure, This procedure is used by IDM or many other.
In this Zip, I just explain how to use of registry in the VB.Net ( As you told me in PM/shoutbox about this )
The rest procedure of days and months must be complete by you.
for any help, msg me
http://www.daniweb.com/images/attachments/4/4a27c1acaf019a0dc83a0d97e4b1ce7e.zip

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.