title: Inno Setup Search for specifc file on a CD, retrieve exact filepath and return value to [Files]-Section
body: <p>I want to make an installer for an old program which comes on 2 CDs and I want to install the files directly from the discs. </p>
  
  <p>At start up the setup should check if a certain file exists which means the first CD is inserted into the cd rom drive.
  This is the code for that task:</p>
  
  <pre><code>[Files]
  Source: {code: ??? }; Destination: {app}; flags:external;
  
  [Code]
  procedure InitializeWizard();
  begin
    if not FileExists('A:\Resource\CD1.GOB') xor
           FileExists('B:\Resource\CD1.GOB') xor
           // and so on, for every drive letter...
           FileExists('Z:\Resource\CD1.GOB') then
           Repeat
             if MsgBox('Insert the first CD!', mbInformation, MB_OKCANCEL) = IDCANCEL then
             ExitProcess(0);
           Until  FileExists('A:\Resource\CD1.GOB') or
                  FileExists('B:\Resource\CD1.GOB') or
                  // going through all letters again...
                  FileExists('Z:\Resource\CD1.GOB') = true;
  </code></pre>
  
  <p>So this works as intended. If the CD is not inserted and thus the file cannot be found a message will be shown which asks the user to insert the CD.</p>
  
  <p>But I am wondering if there is a better way to increment the drive letter, because this is quite a mess.</p>
  
  <p>And second, how can I save the full filepath und pass it on to the [Files] section?</p>
  
  <p>I hope you can help me with this!</p>
  
  <p>UPDATE:</p>
  
  <p>I tried it again and came up with this:</p>
  
  <pre><code>procedure CurPageChanged(CurPageID: Integer);
  begin
    if CurPageId = wpWelcome then
    begin
      WizardForm.NextButton.Enabled := False; 
      repeat
        for i:=0 to 31 do
          dstr := (Chr(Ord('A') + i) + ':\Resource\CD1.gob');
      until FileExists(dstr);
      WizardForm.NextButton.Enabled := True; 
    end;
  end;
  </code></pre>
  
  <p>But using this code Setup freezes at the beginning and doesn't respond even if the CD is already inserted.</p>