program blokfile;
{$APPTYPE CONSOLE}
{$HINTS ON}
uses Windows,WUtils32,Parser32;
procedure Get_LAT(fname:PChar;var lat:TFileTime;var siz:DWord);
var
fh: HFile;
begin
lat.dwLowDateTime:=0;
lat.dwHighDateTime:=0;
siz:=0;
fh:=_lopen(fname,0);
if (fh<>-1) then begin
GetFileTime(fh,nil,nil,@lat);
siz:=GetFileSize(fh,nil);
_lclose(fh);
end;
end;
var
i:Integer;
path: TS255;
h: THandle;
lat1,lat2: TFileTime;
siz1,siz2: DWord;
begin
NextItem(CmdLine,DELIM_CmdLine);
OneItem(CmdLine,DELIM_CmdLine);
if CmdLine[0]=#0 then begin
MessageBox(0,'Dateiname angeben!',nil,0);
exit;
end;
lstrcpy(path,CmdLine);
for i:=lstrlen(path)-1 downto 0 do begin
if path[i] in ['\','/',':'] then begin
path[i]:=#0; {aus Dateiname Pfad abspalten}
break;
end;
end;
Get_LAT(CmdLine,lat1,siz1);
h:=FindFirstChangeNotification(path,false,
FILE_Notify_Change_File_Name or FILE_Notify_Change_Last_Write);
if h<>0 then repeat
WaitForSingleObject(h,Infinite);
Get_LAT(CmdLine,lat2,siz2);
if (siz1<>siz2) or (CompareFileTime(lat1,lat2)<>0) then begin
if siz2>0 then break; {herausfallen und EXIT}
siz1:=siz2;
lat1:=lat2;
end;
FindNextChangeNotification(h);
until false;
end.
Detected encoding: ASCII (7 bit) | 2
|