Well, you did not supply a large enough array for the DirNotes paramater.
And since (IIRC) the RTL is compiled with range-checking off, you don't get a range-check error.
It's your responsibility to supply a large enough array for the function.
This should work.
procedure TestGetDirs(var Path: string);
var
DirNodes: array of PChar;
Res: LongInt;
i: Integer;
begin
SetLength(DirNodes, Length(Path)); //the function cannot return more nodes then the length of the string, so this is definitely safe
Res := GetDirs(Path, DirNodes);
if Res <> -1 then
SetLength(DirNodes,Res)
else
DirNodes := nil;
writeln('GetDirs(Path, DirNodes) = ',Res);
for i := Low(DirNodes) to High(DirNodes) do
writeln(i,': ',DirNodes[i]);
end;
Bart