Skip to content

Commit

Permalink
Win.System: SearchPathForFile - small fixes (FPC compat.)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdp committed Jul 25, 2022
1 parent 0ea0751 commit 04919c6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Base/JPL.Win.System.pas
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,19 @@ function ExitWindows2: Boolean;
function SearchPathForFile(const ShortFileName: string; DefResult: string = ''; PathToSearch: string = ''): string;
var
Buffer: array[0..511] of Char;
lpFilePart: PChar;
dwX: DWORD;
lpFilePart: PChar;
begin
Result := DefResult;
FillChar(Buffer{%H-}, SizeOf(Buffer), 0);
dwX := SearchPath(PChar(PathToSearch), PChar(ShortFileName), nil, Length(Buffer), Buffer, lpFilePart{%H-});
lpFilePart := nil;

if PathToSearch <> '' then
dwX := SearchPath(PChar(PathToSearch), PChar(ShortFileName), nil, Length(Buffer), Buffer, lpFilePart)
else
// [FPC] Taka sytuacja: Bez wynilowania PathToSearch funkcja SearchPath siê wykrzacza.
dwX := SearchPath(nil, PChar(ShortFileName), nil, Length(Buffer), Buffer, lpFilePart);

if dwX = 0 then Exit;
Result := Buffer;
end;
Expand Down

0 comments on commit 04919c6

Please sign in to comment.