AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi FindFirstChangeNotification Thread

FindFirstChangeNotification Thread

Ein Thema von stOrM · begonnen am 29. Sep 2008 · letzter Beitrag vom 2. Okt 2008
Antwort Antwort
Benutzerbild von stOrM
stOrM

Registriert seit: 7. Jun 2003
Ort: Mülheim an der Ruhr
434 Beiträge
 
Delphi 10.3 Rio
 
#1

FindFirstChangeNotification Thread

  Alt 29. Sep 2008, 10:36
Hi,
nur mal ne globale Frage, hat mal jemand, FindFirstChangeNotification unter Vista Ultimate ausprobiert?

Also, unter XP funktionierts hier tadelos, nur unter Vista, werd ich wenn ich Glück habe mal ab und zu über eine Änderung informiert, meistens jedoch gar nicht...

Hat sich beim Aufruf unter Vista was entscheidendes geändert oder ist das einfach ein Fehler?

Gruss
s!
  Mit Zitat antworten Zitat
Benutzerbild von stOrM
stOrM

Registriert seit: 7. Jun 2003
Ort: Mülheim an der Ruhr
434 Beiträge
 
Delphi 10.3 Rio
 
#2

Re: FindFirstChangeNotification Thread

  Alt 2. Okt 2008, 02:09
Zitat von stOrM:
Hi,
nur mal ne globale Frage, hat mal jemand, FindFirstChangeNotification unter Vista Ultimate ausprobiert?

Also, unter XP funktionierts hier tadelos, nur unter Vista, werd ich wenn ich Glück habe mal ab und zu über eine Änderung informiert, meistens jedoch gar nicht...

Hat sich beim Aufruf unter Vista was entscheidendes geändert oder ist das einfach ein Fehler?

Gruss
s!
Mir fehlt im meinem Chaos hier grad wo ich das her hatte, aber es gab hier im Forum glaub ich einen Link zu einer Komponente die das implementiert, ich find hier grad nur auf die schnelle einen Auzug daraus, sollte baer reichen denke ich...

Delphi-Quellcode:
procedure TWatcherThread.Execute;
// There appears to be a bug in win 95 where the bWatchSubTree parameter
// of FindFirstChangeNotification which is a BOOL only accepts values of
// 0 and 1 as valid, rather than 0 and any non-0 value as it should. In D2
// BOOL was defined as 0..1 so the code worked, in D3 it is 0..-1 so
// fails. The result is FindF... produces and error message. This fix (bodge) is
// needed to produce a 0,1 bool pair, rather that 0,-1 as declared in D3
const
  R : array [false..true] of BOOL = (BOOL (0), BOOL (1));
var
  A : array [0..2] of THandle; // used to give the handles to WaitFor...
  B : boolean; // set to true when the thread is to terminate
begin
  SetName;
  B := false;
  A [0] := FDestroyEvent; // put DestroyEvent handle in slot 0
  A [1] := FChangeEvent; // put ChangeEvent handle in slot 1
// make the first call to the change notification system and put the returned
// handle in slot 2.
  A [2] := FindFirstChangeNotification (PChar(FDirectory), R[fSubDirectory], FFilters);
  repeat

// if the change notification handle is invalid then:
    if A [2] = INVALID_HANDLE_VALUE then
    begin
  // call the OnInvalid event

  // wait until either DestroyEvent or the ChangeEvents are signalled
      case WaitForMultipleObjects (2, PWOHandleArray (@A), false, INFINITE) - WAIT_OBJECT_0 of
  // DestroyEvent - close down by setting B to true
        0 : B := true;
  // try new conditions and loop back to the invalid handle test
        1 : A [2] := FindFirstChangeNotification (PChar(FDirectory), R[fSubDirectory], FFilters)
      end
    end else
// handle is valid so wait for any of the change notification, destroy or
// change events to be signalled
      case WaitForMultipleObjects (3, PWOHandleArray (@A), false, INFINITE) - WAIT_OBJECT_0 of
        0 : begin
  // DestroyEvent signalled so use FindClose... and close down by setting B to true
              FindCloseChangeNotification (A [2]);
              B := true
            end;
        1 : begin
  // ChangeEvent signalled so close old conditions by FindClose... and start
  // off new conditions. Loop back to invalid test in case new conditions are
  // invalid
              FindCloseChangeNotification (A [2]);
              A [2] := FindFirstChangeNotification (PChar(FDirectory), R[fSubDirectory], FFilters)
            end;
        2 : begin
  // Notification signalled, so fire the OnChange event and then FindNext..
  // loop back to re-WaitFor... the thread
              Synchronize (InformChange);
              FindNextChangeNotification (A [2])
            end;
      end
  until B;

// closing down so chuck the two events
  CloseHandle (FChangeEvent);
  CloseHandle (FDestroyEvent)
end;
Naja wie gesagt unter XP kein Thema nur unter Vista klappts leider nicht mehr.
Vielleicht hat ja jemand was, das auf Vista und XP funktioniert.

Vielen Dank
s!
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:32 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz