Autor Beitrag
xck3001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 32


D5 Pers, D7 Ent
BeitragVerfasst: Mo 24.10.05 21:00 
Hallo,

ich will alle paar Sekunden auf Laufwerk K:\, das ist mein Kartenleser, zugreifen und ggf. die Dateien von diesem herunterkopieren.

Das Problem: Wenn ich auf K:\ zugreife und keine Karte im Lesegerät steckt, bringt WinXP einen Zugriffsfehler, ganz so wie wenn man auf ein CD-ROM Laufwerk zugreifen will in dem keine CD steckt.
Kann ich das irgendwie abfangen? Habe keine Funktion gefunden um zu testen ob ein Medium im Laufwerk steckt...

Danke!
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 24.10.05 21:14 
Probiers mal So. (Getestet mit XP - Delphi 7)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
function DiskInLw(LW:Char):boolean;
var
 ErrorMode:word;
begin
  ErrorMode:=SetErrorMode(SEM_FailCriticalErrors);
  try
  result:=Diskfree(Ord(upcase(LW)) - $40) > -1;
  finally
  SetErrorMode(ErrorMode);
 end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
     if not DiskInLw('K') then Showmessage('Kein Medium in Laufwerk - K') else Showmessage('Laufwerk - K - ist Bereit');
end;
xck3001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 32


D5 Pers, D7 Ent
BeitragVerfasst: Di 25.10.05 06:26 
Vielen Dank, das funktioniert spitze!