BobKellock
2008-12-02 21:20:35 UTC
Back in February 2007 I posted a message on this board about not
finding all
files with FindFirst/FindNext when executing a real mode BP7 EXE under
XP2 SP2
which runs it via NTVDM.
As there was no response I wrote a fix for it, but, recently I had the
same
problem with another utility (having fogotten about the fix) and found
that it
is a known problem and is published at http://support.microsoft.com/kb/154791
Although Microsft's article imples that the problem is with both
FindFirst and
FindNext I think it's only FindNext that falls over and that it does
work OK
provided that there are no other DOS calls between FindFirst and
FindNext.
Microsoft's solution is to install another version of NTDVM but, even
if you
can find it, it's of no help to other users of the utility if they
haven't got
a suitable version of NTVDM installed.
The fix, that I wrote, (see below) appears to be completely reliable
but is very
slow when there are a large number of files that match the mask.
Do you have a better solution?
Bob
Function FindFirstOrNext(PathAndMask : String;
Att : Byte;
Var SR : SearchRec;
Var Num : LongInt) : Boolean;
Var
SR2 : SearchRec;
N : Word;
DE : Integer;
begin
N := 1;
FindFirst(PandM,Att,SR2);
DE := DosError;
While (DE = 0) AND (N < Num) do
begin
FindNext(SR2);
DE := DosError;
inc(N);
end;
if DE = 0 then
begin
FindFirstOrNext := True;
SR := SR2
end
else
begin
FindFirstOrNext := False;
FindFirst('*.*',AnyFile,SR2);
if DosError = 0 then; {Clears any spurious DOS error 18}
end;
end;
Typical loop
Var SR : SearchRec; SRnum : LongInt;
......
SRnum := 1;
While FindFirstOrNext(C:\Odds\Fred*.*,Archive,SRnum) do
begin
...
...
end;
...
finding all
files with FindFirst/FindNext when executing a real mode BP7 EXE under
XP2 SP2
which runs it via NTVDM.
As there was no response I wrote a fix for it, but, recently I had the
same
problem with another utility (having fogotten about the fix) and found
that it
is a known problem and is published at http://support.microsoft.com/kb/154791
Although Microsft's article imples that the problem is with both
FindFirst and
FindNext I think it's only FindNext that falls over and that it does
work OK
provided that there are no other DOS calls between FindFirst and
FindNext.
Microsoft's solution is to install another version of NTDVM but, even
if you
can find it, it's of no help to other users of the utility if they
haven't got
a suitable version of NTVDM installed.
The fix, that I wrote, (see below) appears to be completely reliable
but is very
slow when there are a large number of files that match the mask.
Do you have a better solution?
Bob
Function FindFirstOrNext(PathAndMask : String;
Att : Byte;
Var SR : SearchRec;
Var Num : LongInt) : Boolean;
Var
SR2 : SearchRec;
N : Word;
DE : Integer;
begin
N := 1;
FindFirst(PandM,Att,SR2);
DE := DosError;
While (DE = 0) AND (N < Num) do
begin
FindNext(SR2);
DE := DosError;
inc(N);
end;
if DE = 0 then
begin
FindFirstOrNext := True;
SR := SR2
end
else
begin
FindFirstOrNext := False;
FindFirst('*.*',AnyFile,SR2);
if DosError = 0 then; {Clears any spurious DOS error 18}
end;
end;
Typical loop
Var SR : SearchRec; SRnum : LongInt;
......
SRnum := 1;
While FindFirstOrNext(C:\Odds\Fred*.*,Archive,SRnum) do
begin
...
...
end;
...