title: How to detect old installation and offer removal?
body: <p>How do I detect whether the user already installed the software and if so, how to offer the possibility of removing the old version?</p>
  
  <p>I have written some lines to check that. Is that correct for now? If this is correct, then how can I let the user choose whether he wants to continue the installation or uninstall the old version?</p>
  
  <pre class="lang-pascal prettyprint-override"><code>#define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\setupname_is1"
  
  var
    uninstallPath: string;
  
  function InitializeSetup: Boolean;
  begin
    if (RegQueryStringValue(HKLM,'{#UNINSTKEY}','UninstallString',uninstallPath)) and
       (uninstallPath &lt;&gt; '') and (fileexists(uninstallPath)) then
    begin
      Result :=
        (MsgBox(CustomMessage('NotVerifiedVersionFound'), mbConfirmation,
                MB_YESNO or MB_DEFBUTTON2) = IDYES);
    end;
    { ... }
  end;
  </code></pre>