Checking and Setting an INI Entry in Innosetup

Here’s a handy bit of code I wrote today for checking and setting an INI entry using the free setup compiler, Innosetup.

procedure CurStepChanged(CurStep: TSetupStep);
    sFirstRun: string;
    if CurStep = ssDone then
          if sFirstRun<>'1' then //we are doing a clean install of version 5 set version 5 database updates to 1 to stop upgrade prompt.

A key thing to note here are that the code is living in the CurStepChanged event and I’m checking that CurStep=ssDone. ssDone represents the successful completion of the installation process. Another item of interest is the ExpandConstant function which is used to access the in-built constants that Innosetup offers.

The reason I’m using this code is to differentiate between a clean install of a program and an install over the top of an existing installation. When any of my programs runs for the first time I write a key (usually FirstRun into section FirstRun) into an ini file. If this key is present then the software has been run at least once. If it’s not present then the installation is a clean one. I can then write an ini entry if it’s a clean install.

This entry was posted in Software on by .

About markn

Mark is the owner and founder of Timesheets MTS Software, an mISV that develops and markets employee timesheet and time clock software. He's also a mechanical engineer, father of four, and a lifelong lover of gadgets.