i didn't get this code to work, but i find another one when i googled on it, so thanks anyway
this is the code i use to get it to work like i wanted
--------------------------------------------------------
If you use drivecombobox component in your applications, probably you are in doubt with the I/O error (21). This error occurs when there is no floppy in drive (for example a

or no disc in cd drives. To avoid this error the code below works.
First of all, if you also use directorylistbox then do not link drivecombobox and directorylistbox. Just do it by adding one extra code into the onchange method of drivecombobox .
Directorylistbox1.drive:=Drivecombobox1.drive;
With this code when you change drives, the directory list updates according to the drive letter given in the onchange method of drivecombobox.
function TForm1.DiskAvail(Drive: Char): Boolean;
var
err_mod: Word;
begin
err_mod := SetErrorMode(SEM_FAILCRITICALERRORS);
//critical errors will not displayed
try
if DiskSize(Ord(Drive) - $40) = - 1 then begin
Result := False; end
else
Result := True;
finally
err_mod := SetErrorMode(err_mod); //reset
end;
end;
After writing the diskavail function which controls whether there is a disk in the drive or not, put the code given below into the onchange method of drivecombobox
procedure TForm1.DriveComboBox1Change(Sender: TObject);
var CurrentDrive: String;
begin
CurrentDrive := DriveComboBox1.Drive + ':';
if not (DiskAvail(CurrentDrive[1])) then
begin showmessage('There is no disk in drive '+CurrentDrive);
DriveComboBox1.Drive := 'C';
end;
Directorylistbox1.drive:=Drivecombobox1.drive;
end;