Code snippit: trial expire

WinBoot

Registered Member
Joined
Aug 25, 2010
Messages
62
Reaction score
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;
}
 
Back
Top