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.
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:
[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;
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.
But I am wondering if there is a better way to increment the drive letter, because this is quite a mess.
And second, how can I save the full filepath und pass it on to the [Files] section?
I hope you can help me with this!
UPDATE:
I tried it again and came up with this:
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;
But using this code Setup freezes at the beginning and doesn't respond even if the CD is already inserted.
Something like this should do what you need: