Monday, 4 August 2014

software expired date set in C#




using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Management;

namespace Lab
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            DateTime ShdtEnd = Convert.ToDateTime("15-Jan-15 12:00:00 AM"); //THIS SOFTWARE EXP DATE
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //  Application.Run(new frmMain());

            //// Application.Run(new frmMain());
            //// }
            if (GetShDate() <= ShdtEnd)
            {
                if (GetMacAddress() == "00270E2F80FB" ||// minnal
                     GetMacAddress() == "002215C6BBF3" //PARTHIBAN
               
                    )
                    //Application.Run(new frmLoginMain());
                    Application.Run(new frmMain());
                //Application.Run(new frmCustomizetools());
                //Application.Run(new frmLoginMain());
                else if (GetVerify() == "Lab Soft")
                {
                    Application.Run(new frmMain());
                    //Application.Run(new frmCustomizetools());
                    //Application.Run(new frmLoginMain());
                    //Application.Run(new frmLoginMain());
                }
                else
                    Application.Run(new frmMain());//frmAuthentication());
                 
            }
            else
            {
                Application.Run(new frmTrialinfor());
            }
        }
        public static string GetMacAddress()
        {
            DateTime dtEnd = Convert.ToDateTime("02-Aug-11 12:00:00 AM");
            ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection moc = mc.GetInstances();
            string MACAddress = String.Empty;
            foreach (ManagementObject mo in moc)
            {
                if (MACAddress == String.Empty) // only return MAC Address from first card
                {
                    if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString();
                }
                mo.Dispose();
            }
            MACAddress = MACAddress.Replace(":", "");
            return MACAddress;
        }
        public static string GetVerify()
        {
            string conread = "";
            StreamReader sr = File.OpenText("E:\\LAB.txt");
            conread = sr.ReadLine();
            return conread;
        }
        public static DateTime GetShDate()
        {
            string dtToday = DateTime.Now.ToShortDateString();
            DateTime dtTo = Convert.ToDateTime(dtToday);
            return dtTo;
        }
    }
}

No comments:

Post a Comment