Autor Beitrag
SKeller
Hält's aus hier
Beiträge: 13

W2k
Delphi 7
BeitragVerfasst: Do 08.04.04 10:03 
lol
Wie kann man prüfen, ob auf eine Datei von einem anderen Programm zugegriffen wird?
z.B. eine Textdatei, die von einem Programm beschrieben und vom anderen gelesen wird.

Please help!!! :-D
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 08.04.04 10:15 
also ich hab mal folgenden code irgendwo gelsesen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
function IsFileInUse(s: string): boolean;
var
  HFileRes : HFILE;
begin
  // Standardergebnis (= FALSE = Datei wird nicht benutzt)
  Result   := false;

  // wenn die Datei nicht existiert, Funktion beenden
  if(not fileexists(s)) then exit;

  // Datei öffnen
  HFileRes := CreateFile(pchar(s),
    GENERIC_READ or GENERIC_WRITE,
    0,
    nil,
    OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,
    0);

  // wenn die Datei benutzt wird, ist das Ergebnis von
  // "HFileRes" = INVALID_HANDLE_VALUE; die Funktion
  // liefert dann TRUE zurück
  Result   := (HFileRes = INVALID_HANDLE_VALUE);

  // wenn nicht, muss die geöffnete Datei geschlossen
  // werden
  if(not Result) then CloseHandle(HFileRes);
end;

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 08.04.04 12:26 
Das sollte aber nur gehen, wenn die Datei exklusiv geöffnet ist. Desweiteren hatten wir das schon öfters. Bitte die Forensuche anschmeißen. ;)
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 08.04.04 14:07 
was meinst du mit exklusiv geöffnet ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 08.04.04 14:15 
Kuck dir mal die Zugriffsmodus-Konstanten von den Datei Funktionen an.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 08.04.04 16:32 
achso. versteh schon

_________________
In the beginning was the word.
And the word was content-type: text/plain.
SKeller Threadstarter
Hält's aus hier
Beiträge: 13

W2k
Delphi 7
BeitragVerfasst: Fr 09.04.04 13:09 
Thank you!!! :D