Autor Beitrag
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 08.07.03 12:38 
Wie kann ich verhindern, dass DirectoryExists('A:\'); bei fehlender Diskette unter NT4 (unter XP, 2000 und 2003 passiert das nicht!) einen Fehlerdialog öffnet...
user defined image

Das ist besonders bei einer Serveranwendung ziemlich lästig, da man ja nicht ständig zum Server rennen kann um zu bestätigen...

_________________
Michael
(principal certified lotus professional - developer)


Zuletzt bearbeitet von FriFra am Do 17.07.03 22:56, insgesamt 2-mal bearbeitet
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Di 08.07.03 13:05 
Hallo,
hast du dir mal den kompierschalter {I+} bzw {I-} angeschaut? Wenn du die verwendest musst du nur noch explizit auf IOResult = 0 testen.

Gruß
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 08.07.03 13:13 
packe die if abfrage doch einfach in einer
try
except
end;
block rein und fertig.

_________________
MFG
Michael Springwald, "kann kein englisch...."
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 08.07.03 13:15 
Ich hab jetzt mal direkt unter Implementation folgendes eingefügt:
ausblenden Delphi-Quelltext
1:
2:
{$I-}
{$IOCHECKS OFF}


Allerdings hat das keinerlei Auswirkungen...

_________________
Michael
(principal certified lotus professional - developer)
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 08.07.03 13:16 
mimi hat folgendes geschrieben:
packe die if abfrage doch einfach in einer
try
except
end;
block rein und fertig.


Nix fertig... So einfach ist es leider nicht...

_________________
Michael
(principal certified lotus professional - developer)
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 08.07.03 13:24 
nartürlich, das dialog kommt nicht mehr:)
und das war doch das ziel oder nicht ?

_________________
MFG
Michael Springwald, "kann kein englisch...."
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Di 08.07.03 13:25 
Es geht so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function DirectoryExistsEx(const Directory: string): Boolean;
var
  ErrorMode: Cardinal;
begin
  ErrorMode := SetErrorMode(EM_FAILCRITICALERRORS);
  try
    Result := DirectoryExists(Directory);
  finally
    SetErrorMode(ErrorMode);
  end;
end;

_________________
Ist Zeit wirklich Geld?
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 08.07.03 13:29 
mimi hat folgendes geschrieben:
nartürlich, das dialog kommt nicht mehr:)
und das war doch das ziel oder nicht ?


NEIN, der Dialog kommt noch!!!

_________________
Michael
(principal certified lotus professional - developer)
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 08.07.03 13:33 
@AndyB: In welcher Unit ist EM_FAILCRITICALERRORS deklariert?

_________________
Michael
(principal certified lotus professional - developer)
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 08.07.03 13:37 
wenn man es richtig macht dürfte kein dialog kommen es sei den die funktion löst kein excepition aus. oder wie das heißt, das könnte natürlich sein.

_________________
MFG
Michael Springwald, "kann kein englisch...."
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 08.07.03 13:38 
mimi hat folgendes geschrieben:
wenn man es richtig macht dürfte kein dialog kommen es sei den die funktion löst kein excepition aus. oder wie das heißt, das könnte natürlich sein.


:evil: Hör endlich auf! Ich hab Dir schon mehrmals gesagt, dass es so nicht geht... DirectoryExists löst KEINE Exception aus, es kommt nur dieser blöde Dialog... Wenn es so einfach wäre, hätte ich ganz sicher nicht gefragt!

_________________
Michael
(principal certified lotus professional - developer)
Tana´Ri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Di 08.07.03 13:45 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Button1Click(Sender: TObject);

      function DirectoryExistsEx(const Directory: string): Boolean;
        var ErrorMode: Cardinal;
       begin
        ErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
        try
          Result := DirectoryExists(Directory);
        except
         SetErrorMode(ErrorMode);
        end;
      end;

begin
   DirectoryExistsEx('A:\');
end;


fehlerhaft EM_FAILCRITICALERRORS (S fehlt)
richtig -> SEM_FAILCRITICALERRORS

_________________
mfg
Tana´Ri
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 08.07.03 13:50 
@Tana'Ri, AndyB: :D Danke! Jetzt funktioniert es.
:dance: :dance2: :beer:

_________________
Michael
(principal certified lotus professional - developer)
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 08.07.03 13:55 
FriFra hat folgendes geschrieben:
:evil: Hör endlich auf! [...]

Warum schreist´n den armen mimi so an? Nicht, dass ich ihn unbedingt leiden kann; bei das Teutsch, wo er benutzt ... :mrgreen: ... aber er versucht doch auch bloß, dir zu helfen. btw: Meine Funktion sieht (altertümlich) so aus und funktioniert problemlos:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
function DirectoryExists(const szDirName: string): boolean;
var
  tmp : string;
begin
  {$I-}
  GetDir(0,tmp); ChDir(szDirName); Result := (IoResult = 0); ChDir(tmp);
  {$I+}
end;

Du kannst auch Borlands Grundlage von "fileexists" benutzen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function fileexists(const szFilename: string): boolean;
var
  Handle   : THandle;
  FindData : TWin32FindData;
begin
  Handle := FindFirstFile(pchar(szFilename),FindData);
  Result := (Handle <> INVALID_HANDLE_VALUE);

  if(Result) then Windows.FindClose(Handle);
end;

{ ... }

if(fileexists('c:\Programme')) then ShowMessage('OK');

Getestet unter Win98. Ergebnis: klappt. :)
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 08.07.03 14:03 
@MathiasSimmack: Auch Danke für Deine Tips ;)

...mimi habe ich angeschrien, weil ich mich drüber aufgeregt habe, das 3x das gleiche kam, obwohl das mimi es offensichtlich selbst nie getestet hat und obwohl ich schon nach dem ersten Tip gesagt hatte, das es so nicht geht...

_________________
Michael
(principal certified lotus professional - developer)
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Di 08.07.03 16:15 
Tana´Ri hat folgendes geschrieben:
fehlerhaft EM_FAILCRITICALERRORS (S fehlt)
richtig -> SEM_FAILCRITICALERRORS

Das hat man nun, vom Copy & Paste aus dem Win32SDK. :cry:

_________________
Ist Zeit wirklich Geld?
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Do 17.07.03 22:56 
Leider kommt der Dialog trotz:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function DirectoryExistsEx(const Directory: string): Boolean; 
var
  ErrorMode: Cardinal; 
begin 
  ErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS); 
  try 
    Result := DirectoryExists(Directory); 
  except 
    SetErrorMode(ErrorMode); 
  end
end;


unter NT4 sporadisch (im Durchschnitt bei jedem 100. Aufruf :roll: ) noch vor :cry: ! Wie kann das sein? ...und wie kann ich das endgültig und sicher abstellen?

_________________
Michael
(principal certified lotus professional - developer)