Use GetProcAddress to set GetFinalPathNameByHandle function pointer

This commit is contained in:
Pierre Muller 2024-01-06 17:12:38 +01:00
parent 6ab2cd3ce9
commit f510e6f59b

View File

@ -646,7 +646,10 @@ begin
end; end;
end; end;
function GetFinalPathNameByHandle(aHandle : THandle; Buf : LPSTR; BufSize : DWord; Flags : DWord) : DWORD; external 'kernel32' name 'GetFinalPathNameByHandleA'; type
TGetFinalPathNameByHandle = function(aHandle : THandle; Buf : LPSTR; BufSize : DWord; Flags : DWord) : DWORD;
var
GetFinalPathNameByHandle:TGetFinalPathNameByHandle=nil;
Const Const
VOLUME_NAME_NT = $2; VOLUME_NAME_NT = $2;
@ -664,7 +667,7 @@ begin
FillChar(Buf,MAX_PATH+1,0); FillChar(Buf,MAX_PATH+1,0);
if Not FileExists(aLink,False) then if Not FileExists(aLink,False) then
exit; exit;
if not CheckWin32Version(6, 0) then if not CheckWin32Version(6, 0) or not(assigned(GetFinalPathNameByHandle)) then
exit; exit;
Attrs:=GetFileAttributes(PAnsiChar(aLink)); Attrs:=GetFileAttributes(PAnsiChar(aLink));
if (Attrs=INVALID_FILE_ATTRIBUTES) or ((Attrs and faSymLink)=0) then if (Attrs=INVALID_FILE_ATTRIBUTES) or ((Attrs and faSymLink)=0) then
@ -1718,6 +1721,8 @@ begin
// GetTimeZoneInformationForYear is supported only on Vista and newer // GetTimeZoneInformationForYear is supported only on Vista and newer
if (kernel32dll<>0) and (Win32MajorVersion>=6) then if (kernel32dll<>0) and (Win32MajorVersion>=6) then
GetTimeZoneInformationForYear:=TGetTimeZoneInformationForYear(GetProcAddress(kernel32dll,'GetTimeZoneInformationForYear')); GetTimeZoneInformationForYear:=TGetTimeZoneInformationForYear(GetProcAddress(kernel32dll,'GetTimeZoneInformationForYear'));
if (kernel32dll<>0) then
GetFinalPathNameByHandle:=TGetFinalPathNameByHandle(GetProcAddress(kernel32dll,'GetFinalPathNameByHandleA'));
end; end;
Function GetAppConfigDir(Global : Boolean) : String; Function GetAppConfigDir(Global : Boolean) : String;