PDA

View Full Version : Check for CD files..?


MachTwo
08-21-2005, 04:45 PM
I would like my installer to check for a product CD before allowing the user to continue with the installation.

I have the following code used in On Start:

tblDrives = Drive.Enumerate();
if(tblDrives)then
for i, strDrive in tblDrives do
nType = Drive.GetType(strDrive);
if(nType == 5)then
tblResults = File.Find(strDrive,"*.*", true, false, nil);
if tblResults then
Altcd = 1;
else
Altcd = 2;
end

if Altcd == 2 then
result = Dialog.Message("Notice", "The specified file does not exist.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
end
end
end


The problem is that I have 2 CD drives. With the above code and the product CD in one drive, the absence of a product CD (or any CD in the above example) in the second CD drive causes the message box to display.

Is there a way to work around this? Any suggestions would be appreciated.

Corey
08-21-2005, 04:51 PM
I'm sure someone will be able to answer this. In the meantime I checked out your profile link to that Concorde add-on for MS flight simulator, pretty neat. I know there's some mighty big fans of MS flight simulator around here. :yes

csd214
08-22-2005, 02:08 PM
Use the function g_GetDriveLetters() (in _SUF70_Global_Functions.lua) with the argument DRIVE_CDROM.

tCDdrives = g_GetDriveLetters(DRIVE_CDROM);
if tCDdrives then
sCDdrive = "";
for index, data in tCDdrives do
sCDdrive = sCDdrive..data;
end
Dialog.Message("CD Drives", sCDdrive);

End

Test each entry in the table until you find your file (while/end).

There is a lot of gunpowder in _SUF70_Global_Functions.lua.

MachTwo
08-22-2005, 06:15 PM
Thanks for your suggestion csd214. I’ve played around with the code and used a short loop to check any CD drives before presenting the user with the installer interface, or an error message requesting that the CD be placed in the CD drive.

reflexive
11-16-2005, 08:30 AM
How can I check if a CD is in drive, without knowing anything about that CD?

csd214
11-22-2005, 05:29 AM
Welcome to the forum, Reflexive. Sorry you had to wait for an answer.

A suggestion to achieve what you want:

sCdDrive = "G:"; -- drive letter is determined
tInfo = Drive.GetInformation(sCdDrive);
nError = Application.GetLastError();
if (nError ~= 0) then
-- some kind of error has occurred!
if nError == 2104 then
-- Error #2104 = "Failed to get volume information."
Dialog.Message("Error", "Drive "..sCdDrive.." is empty!");
-- else
-- Dialog.Message("Feil ", "Feil # " ..nError.."\r\n".. _tblErrorMessages[nError], MB_OK, MB_ICONSTOP);
end
Application.ExitScript(); -- a usefull command!
end

Dialog.Message("Drive "..sCdDrive, "CD is found. The drive is NOT empty.", MB_OK, MB_ICONINFORMATION);
:)