Esempio n. 1
0
	//*************************************************************************
	// Method:		LoadDataFromRegistry
	// Description: loads the serial number and registration key from the registry
	//	and decodes the information
	//
	// Parameters:
	//	None
	//
	// Return Value: None
	//*************************************************************************
	void RegistrationMgr::LoadDataFromRegistry()
	{
		Registry registry;

		regData->SetCustomerType(NormalCustomer);
		regData->SetNumberOfDaysValid(15);
		regData->SetFunctionalityType(TimeTrial);
		regData->SetProductType(Holodeck);
		regData->SetKeyVersion(HolodeckBasic);
		regData->SetNumberOfLicensesPurchased(0);
		regData->SetSerialNumber("");
		regData->SetRegistrationKey("");

		if (!registry.OpenKey(ROOT_KEY, ROOT_PATH, KEY_QUERY_VALUE))
			return;

		SiString serialNum, regKey;
		if (!registry.Read(SERIAL_NUMBER_VALUE_NAME, serialNum))
			return;

		if (!registry.Read(REGISTRATION_KEY_VALUE_NAME, regKey))
			return;

		regData->SetSerialNumber(serialNum);
		regData->SetRegistrationKey(regKey);

		RegistrationKeyGenerator::GetInstance()->DecodeRegistrationKey(regData);
	}
Esempio n. 2
0
	//*************************************************************************
	// Method:		GetNumberOfDaysRemaining
	// Description: returns the number of days remaining for this license
	//
	// Parameters:
	//	None
	//
	// Return Value: the number of days remaining for this license
	//*************************************************************************
	int RegistrationMgr::GetNumberOfDaysRemaining()
	{
		DWORD dwHighValue, dwLowValue;
		::FILETIME currentFileTime;
		ULARGE_INTEGER trialStartTime, currentTime, calculatedTime;
		int numDays;
		Registry registry;

		if (!registry.OpenKey(ROOT_KEY, ROOT_PATH, KEY_QUERY_VALUE))
			return 0;

		if (!registry.Read("Config1", dwHighValue))
			return 0;

		if (!registry.Read("Config2", dwLowValue))
			return 0;

		trialStartTime.HighPart = dwHighValue;
		trialStartTime.LowPart = dwLowValue;

		GetSystemTimeAsFileTime(&currentFileTime);
		currentTime.HighPart = currentFileTime.dwHighDateTime;
		currentTime.LowPart = currentFileTime.dwLowDateTime;

		calculatedTime.QuadPart = currentTime.QuadPart - trialStartTime.QuadPart;
        numDays = (int)((calculatedTime.QuadPart * .0000001) / 86400);	//calculated in 100ns increments

		return GetNumberOfDaysValid() - numDays;
	}