I am using Inno Setup compiler to create an installer set up for my software. The installer adds a timestamp to the Windows registry during the first installation. When the software is reinstalled, it checks the saved timestamp in Windows registry and if it is more than 90 days from the current date then it should stop the installation? so I am forcing the user to use the software only for 90 days.
I am trying to add 90 days to the current datetime for comparison. There is no option to do this in the datatype TSystemTime
. I can add days to a TDateTime
variable, but I can't use that variable in the Inno Setup script.
This is my code
function InitializeSetup(): Boolean;
var
InstallDatetime: string;
begin
if RegQueryStringValue(HKLM, 'Software\Company\Player\Settings', 'DateTimeInstall', InstallDatetime) then
{ I want to add 90 days before comparison }
Result := CompareStr(GetDateTimeString('yyyymmdd', #0,#0), InstallDatetime) <= 0;
if not result then
MsgBox('This Software trial period is over. The Program will not install.', mbError, MB_OK);
Result := True;
end;
I have seen a similar example on Stack Overflow. They have used a constant to compare the datetime. Instead, I am adding 90 days to my saved installation datetime.
Any help will be much appreciated.