1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Code snippit: trial expire

Discussion in 'C, C++, C#' started by WinBoot, Sep 7, 2010.

  1. WinBoot

    WinBoot Registered Member

    Joined:
    Aug 25, 2010
    Messages:
    61
    Likes Received:
    14
    Code:
    //==================================================================================
    int daysInMonth( int curMonth )
    {
    	if ( curMonth == 1 ||
       curMonth == 3 ||
       curMonth == 5 ||
       curMonth == 7 ||
       curMonth == 8 ||
       curMonth == 10 ||
       curMonth == 12)
      return 31;
    	else if ( !( curMonth == 2 ) )
      return 30;
    	else
      return 27;
    }
    
    //==================================================================================
    int checkTrialExpired( )
    {
    	int expTime = 30;
    
    	int startDay = 13;
    	int startMonth = 12;
    	int startYear = 2005;
    
    	SYSTEMTIME sysTime;
    	GetLocalTime(&sysTime);
    
    	int daysLeftInMonth = daysInMonth( startMonth ) - startDay;
    	int daysLeftInNextMonth = expTime - daysLeftInMonth;
    	int daysTotalLeft;
    
    	if ( sysTime.wMonth != startMonth )
      daysTotalLeft = expTime - ( sysTime.wDay - startDay + daysInMonth( startMonth ) );
    	else
      daysTotalLeft = expTime - ( sysTime.wDay - startDay );
    
    	if ( sysTime.wYear == startYear )
    	{
      if ( sysTime.wDay > ( daysLeftInNextMonth + startDay ) )
      	return 0;
      else
      	return daysTotalLeft;
    	}
    	else
      return daysTotalLeft;
    }