1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-04-07 06:50:04 +02:00

Fixed Unicode strings issue with Windows API calls

Added more NIL checks in TChromiumCore
This commit is contained in:
Salvador Díaz Fau 2020-06-13 17:24:22 +02:00
parent ef46244dde
commit 0be9d32bc3
4 changed files with 183 additions and 141 deletions

View File

@ -235,10 +235,10 @@ type
procedure SetLocalesDirPath(const aValue : ustring); procedure SetLocalesDirPath(const aValue : ustring);
procedure SetOsmodalLoop(aValue : boolean); procedure SetOsmodalLoop(aValue : boolean);
function GetChromeVersion : string; function GetChromeVersion : ustring;
function GetLibCefVersion : string; function GetLibCefVersion : ustring;
function GetLibCefPath : string; function GetLibCefPath : ustring;
function GetChromeElfPath : string; function GetChromeElfPath : ustring;
function GetMustCreateResourceBundleHandler : boolean; virtual; function GetMustCreateResourceBundleHandler : boolean; virtual;
function GetMustCreateBrowserProcessHandler : boolean; virtual; function GetMustCreateBrowserProcessHandler : boolean; virtual;
function GetMustCreateRenderProcessHandler : boolean; virtual; function GetMustCreateRenderProcessHandler : boolean; virtual;
@ -457,10 +457,10 @@ type
property ChromeMinorVer : uint16 read FChromeVersionInfo.MinorVer; property ChromeMinorVer : uint16 read FChromeVersionInfo.MinorVer;
property ChromeRelease : uint16 read FChromeVersionInfo.Release; property ChromeRelease : uint16 read FChromeVersionInfo.Release;
property ChromeBuild : uint16 read FChromeVersionInfo.Build; property ChromeBuild : uint16 read FChromeVersionInfo.Build;
property ChromeVersion : string read GetChromeVersion; property ChromeVersion : ustring read GetChromeVersion;
property LibCefVersion : string read GetLibCefVersion; property LibCefVersion : ustring read GetLibCefVersion;
property LibCefPath : string read GetLibCefPath; property LibCefPath : ustring read GetLibCefPath;
property ChromeElfPath : string read GetChromeElfPath; property ChromeElfPath : ustring read GetChromeElfPath;
property LibLoaded : boolean read FLibLoaded; property LibLoaded : boolean read FLibLoaded;
property LogProcessInfo : boolean read FLogProcessInfo write FLogProcessInfo; property LogProcessInfo : boolean read FLogProcessInfo write FLogProcessInfo;
property ReRaiseExceptions : boolean read FReRaiseExceptions write FReRaiseExceptions; property ReRaiseExceptions : boolean read FReRaiseExceptions write FReRaiseExceptions;
@ -833,12 +833,12 @@ begin
// Is implemented by TCefApplication // Is implemented by TCefApplication
end; end;
function TCefApplicationCore.GetChromeVersion : string; function TCefApplicationCore.GetChromeVersion : ustring;
begin begin
Result := FileVersionInfoToString(FChromeVersionInfo); Result := FileVersionInfoToString(FChromeVersionInfo);
end; end;
function TCefApplicationCore.GetLibCefVersion : string; function TCefApplicationCore.GetLibCefVersion : ustring;
begin begin
Result := IntToStr(CEF_SUPPORTED_VERSION_MAJOR) + '.' + Result := IntToStr(CEF_SUPPORTED_VERSION_MAJOR) + '.' +
IntToStr(CEF_SUPPORTED_VERSION_MINOR) + '.' + IntToStr(CEF_SUPPORTED_VERSION_MINOR) + '.' +
@ -846,7 +846,7 @@ begin
IntToStr(CEF_SUPPORTED_VERSION_BUILD); IntToStr(CEF_SUPPORTED_VERSION_BUILD);
end; end;
function TCefApplicationCore.GetLibCefPath : string; function TCefApplicationCore.GetLibCefPath : ustring;
begin begin
if (length(FFrameworkDirPath) > 0) then if (length(FFrameworkDirPath) > 0) then
Result := IncludeTrailingPathDelimiter(FFrameworkDirPath) + LIBCEF_DLL Result := IncludeTrailingPathDelimiter(FFrameworkDirPath) + LIBCEF_DLL
@ -854,7 +854,7 @@ begin
Result := LIBCEF_DLL; Result := LIBCEF_DLL;
end; end;
function TCefApplicationCore.GetChromeElfPath : string; function TCefApplicationCore.GetChromeElfPath : ustring;
begin begin
if (length(FFrameworkDirPath) > 0) then if (length(FFrameworkDirPath) > 0) then
Result := IncludeTrailingPathDelimiter(FFrameworkDirPath) + CHROMEELF_DLL Result := IncludeTrailingPathDelimiter(FFrameworkDirPath) + CHROMEELF_DLL
@ -2006,6 +2006,9 @@ end;
function TCefApplicationCore.LoadCEFlibrary : boolean; function TCefApplicationCore.LoadCEFlibrary : boolean;
var var
TempOldDir, TempString : string; TempOldDir, TempString : string;
{$IFDEF MSWINDOWS}
TempError : DWORD;
{$ENDIF}
begin begin
Result := False; Result := False;
@ -2025,7 +2028,7 @@ begin
end; end;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
FLibHandle := LoadLibraryEx(PChar(LibCefPath), 0, LOAD_WITH_ALTERED_SEARCH_PATH); FLibHandle := LoadLibraryExW(PWideChar(LibCefPath), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
{$ELSE} {$ELSE}
FLibHandle := LoadLibrary(PChar(LibCefPath)); FLibHandle := LoadLibrary(PChar(LibCefPath));
{$ENDIF} {$ENDIF}
@ -2035,8 +2038,10 @@ begin
FStatus := asErrorLoadingLibrary; FStatus := asErrorLoadingLibrary;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
TempError := GetLastError;
TempString := 'Error loading libcef.dll' + CRLF + CRLF + TempString := 'Error loading libcef.dll' + CRLF + CRLF +
'Error code : 0x' + inttohex(GetLastError, 8); 'Error code : 0x' + inttohex(TempError, 8) + CRLF +
SysErrorMessage(TempError);
{$ELSE} {$ELSE}
TempString := 'Error loading the CEF binaries'; TempString := 'Error loading the CEF binaries';
{$ENDIF} {$ENDIF}

View File

@ -1175,9 +1175,13 @@ end;
procedure TChromiumCore.DestroyAllBrowsers; procedure TChromiumCore.DestroyAllBrowsers;
begin begin
FBrowsersCS.Acquire; if (FBrowsersCS <> nil) then
if (FBrowsers <> nil) then FreeAndNil(FBrowsers); try
FBrowsersCS.Release; FBrowsersCS.Acquire;
if (FBrowsers <> nil) then FreeAndNil(FBrowsers);
finally
FBrowsersCS.Release;
end;
end; end;
procedure TChromiumCore.BeforeDestruction; procedure TChromiumCore.BeforeDestruction;
@ -1619,7 +1623,7 @@ begin
if not(csDesigning in ComponentState) and if not(csDesigning in ComponentState) and
(BrowserId = 0) and (BrowserId = 0) and
(GlobalCEFApp <> nil) and (GlobalCEFApp <> nil) and
GlobalCEFApp.GlobalContextInitialized and GlobalCEFApp.GlobalContextInitialized and
CreateClientHandler(not(ValidCefWindowHandle(aParentHandle))) then CreateClientHandler(not(ValidCefWindowHandle(aParentHandle))) then
begin begin
GetSettings(FBrowserSettings); GetSettings(FBrowserSettings);
@ -1879,12 +1883,13 @@ end;
procedure TChromiumCore.CloseAllBrowsers; procedure TChromiumCore.CloseAllBrowsers;
begin begin
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
if (FBrowsers <> nil) then FBrowsers.CloseAllBrowsers; FBrowsersCS.Acquire;
finally if (FBrowsers <> nil) then FBrowsers.CloseAllBrowsers;
FBrowsersCS.Release; finally
end; FBrowsersCS.Release;
end;
end; end;
function TChromiumCore.TryCloseBrowser : boolean; function TChromiumCore.TryCloseBrowser : boolean;
@ -2381,65 +2386,75 @@ function TChromiumCore.GetBrowser : ICefBrowser;
begin begin
Result := nil; Result := nil;
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
FBrowsersCS.Acquire;
if (FBrowsers <> nil) then if (FBrowsers <> nil) then
begin begin
if FMultiBrowserMode then if FMultiBrowserMode then
Result := FBrowsers.Browser[FBrowserId] Result := FBrowsers.Browser[FBrowserId]
else else
Result := FBrowsers.FirstBrowser; Result := FBrowsers.FirstBrowser;
end; end;
finally finally
FBrowsersCS.Release; FBrowsersCS.Release;
end; end;
end; end;
function TChromiumCore.GetBrowserId : integer; function TChromiumCore.GetBrowserId : integer;
begin begin
FBrowsersCS.Acquire; Result := 0;
Result := FBrowserId;
FBrowsersCS.Release; if (FBrowsersCS <> nil) then
try
FBrowsersCS.Acquire;
Result := FBrowserId;
finally
FBrowsersCS.Release;
end;
end; end;
function TChromiumCore.GetBrowserById(aID : integer) : ICefBrowser; function TChromiumCore.GetBrowserById(aID : integer) : ICefBrowser;
begin begin
Result := nil; Result := nil;
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
if (FBrowsers <> nil) then FBrowsersCS.Acquire;
Result := FBrowsers.Browser[aID]; if (FBrowsers <> nil) then
finally Result := FBrowsers.Browser[aID];
FBrowsersCS.Release; finally
end; FBrowsersCS.Release;
end;
end; end;
function TChromiumCore.GetBrowserCount : integer; function TChromiumCore.GetBrowserCount : integer;
begin begin
Result := 0; Result := 0;
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
if (FBrowsers <> nil) then FBrowsersCS.Acquire;
Result := FBrowsers.Count; if (FBrowsers <> nil) then
finally Result := FBrowsers.Count;
FBrowsersCS.Release; finally
end; FBrowsersCS.Release;
end;
end; end;
function TChromiumCore.GetBrowserIdByIndex(aIndex : integer) : integer; function TChromiumCore.GetBrowserIdByIndex(aIndex : integer) : integer;
begin begin
Result := 0; Result := 0;
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
if (FBrowsers <> nil) and (aIndex >= 0) and (aIndex < FBrowsers.Count) then FBrowsersCS.Acquire;
Result := TBrowserInfo(FBrowsers[aIndex]).ID; if (FBrowsers <> nil) and (aIndex >= 0) and (aIndex < FBrowsers.Count) then
finally Result := TBrowserInfo(FBrowsers[aIndex]).ID;
FBrowsersCS.Release; finally
end; FBrowsersCS.Release;
end;
end; end;
function TChromiumCore.GetHasValidMainFrame : boolean; function TChromiumCore.GetHasValidMainFrame : boolean;
@ -2513,9 +2528,15 @@ end;
function TChromiumCore.GetInitialized : boolean; function TChromiumCore.GetInitialized : boolean;
begin begin
FBrowsersCS.Acquire; Result := False;
Result := (FBrowserId <> 0) and (FBrowsers <> nil) and not(FBrowsers.BrowserIsClosing[FBrowserId]);
FBrowsersCS.Release; if (FBrowsersCS <> nil) then
try
FBrowsersCS.Acquire;
Result := (FBrowserId <> 0) and (FBrowsers <> nil) and not(FBrowsers.BrowserIsClosing[FBrowserId]);
finally
FBrowsersCS.Release;
end;
end; end;
function TChromiumCore.GetDocumentURL : ustring; function TChromiumCore.GetDocumentURL : ustring;
@ -3585,7 +3606,7 @@ begin
TempLanguagesList := FAcceptLanguageList; TempLanguagesList := FAcceptLanguageList;
if (length(TempLanguagesList) = 0) then if (length(TempLanguagesList) = 0) and (FOptions <> nil) then
TempLanguagesList := FOptions.AcceptLanguageList; TempLanguagesList := FOptions.AcceptLanguageList;
if (length(TempLanguagesList) = 0) then if (length(TempLanguagesList) = 0) then
@ -4764,81 +4785,86 @@ function TChromiumCore.RemoveBrowser(const aBrowser : ICefBrowser) : boolean;
begin begin
Result := False; Result := False;
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
FBrowsersCS.Acquire;
if (aBrowser <> nil) and (FBrowsers <> nil) then if (aBrowser <> nil) and (FBrowsers <> nil) then
begin begin
if FBrowsers.RemoveBrowser(aBrowser) and if FBrowsers.RemoveBrowser(aBrowser) and
(FBrowserId = aBrowser.Identifier) then (FBrowserId = aBrowser.Identifier) then
FBrowserId := FBrowsers.FirstID; FBrowserId := FBrowsers.FirstID;
end; end;
finally finally
FBrowsersCS.Release; FBrowsersCS.Release;
end; end;
end; end;
function TChromiumCore.AddBrowser(const aBrowser : ICefBrowser) : boolean; function TChromiumCore.AddBrowser(const aBrowser : ICefBrowser) : boolean;
begin begin
Result := False; Result := False;
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
FBrowsersCS.Acquire;
if (aBrowser <> nil) and if (aBrowser <> nil) and
(FBrowsers <> nil) and (FBrowsers <> nil) and
(FMultiBrowserMode or (FBrowsers.Count = 0)) and (FMultiBrowserMode or (FBrowsers.Count = 0)) and
FBrowsers.AddBrowser(aBrowser) then FBrowsers.AddBrowser(aBrowser) then
begin begin
Result := True; Result := True;
if (FBrowserId = 0) then if (FBrowserId = 0) then
FBrowserId := aBrowser.Identifier; FBrowserId := aBrowser.Identifier;
end; end;
finally finally
FBrowsersCS.Release; FBrowsersCS.Release;
end; end;
end; end;
function TChromiumCore.SelectBrowser(aID : integer) : boolean; function TChromiumCore.SelectBrowser(aID : integer) : boolean;
begin begin
Result := False; Result := False;
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
FBrowsersCS.Acquire;
if FMultiBrowserMode and (FBrowsers <> nil) and (FBrowsers.SearchBrowser(aID) >= 0) then if FMultiBrowserMode and (FBrowsers <> nil) and (FBrowsers.SearchBrowser(aID) >= 0) then
begin begin
FBrowserId := aID; FBrowserId := aID;
Result := True; Result := True;
end; end;
finally finally
FBrowsersCS.Release; FBrowsersCS.Release;
end; end;
end; end;
function TChromiumCore.IndexOfBrowserID(aID : integer) : integer; function TChromiumCore.IndexOfBrowserID(aID : integer) : integer;
begin begin
Result := -1; Result := -1;
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
FBrowsersCS.Acquire;
if (FBrowsers <> nil) then if (FBrowsers <> nil) then
Result := FBrowsers.SearchBrowser(aID); Result := FBrowsers.SearchBrowser(aID);
finally finally
FBrowsersCS.Release; FBrowsersCS.Release;
end; end;
end; end;
procedure TChromiumCore.SetBrowserIsClosing(aID : integer); procedure TChromiumCore.SetBrowserIsClosing(aID : integer);
begin begin
try if (FBrowsersCS <> nil) then
FBrowsersCS.Acquire; try
if (FBrowsers <> nil) then FBrowsers.BrowserIsClosing[aID] := True; FBrowsersCS.Acquire;
finally if (FBrowsers <> nil) then FBrowsers.BrowserIsClosing[aID] := True;
FBrowsersCS.Release; finally
end; FBrowsersCS.Release;
end;
end; end;
function TChromiumCore.doOnClose(const browser: ICefBrowser): Boolean; function TChromiumCore.doOnClose(const browser: ICefBrowser): Boolean;

View File

@ -212,9 +212,10 @@ function CefClearCrossOriginWhitelist: Boolean;
procedure UInt64ToFileVersionInfo(const aVersion : uint64; var aVersionInfo : TFileVersionInfo); procedure UInt64ToFileVersionInfo(const aVersion : uint64; var aVersionInfo : TFileVersionInfo);
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
function GetExtendedFileVersion(const aFileName : string) : uint64; function GetExtendedFileVersion(const aFileName : ustring) : uint64;
function GetStringFileInfo(const aFileName, aField : string; var aValue : string) : boolean; function GetStringFileInfo(const aFileName, aField : string; var aValue : string) : boolean;
function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersionInfo) : boolean; function GetDLLVersion(const aDLLFile : ustring; var aVersionInfo : TFileVersionInfo) : boolean;
procedure OutputLastErrorMessage;
{$ENDIF} {$ENDIF}
function SplitLongString(aSrcString : string) : string; function SplitLongString(aSrcString : string) : string;
@ -224,8 +225,8 @@ function CheckLocales(const aLocalesDirPath : string; var aMissingFiles : string
function CheckResources(const aResourcesDirPath : string; var aMissingFiles : string; aCheckDevResources: boolean = True; aCheckExtensions: boolean = True) : boolean; function CheckResources(const aResourcesDirPath : string; var aMissingFiles : string; aCheckDevResources: boolean = True; aCheckExtensions: boolean = True) : boolean;
function CheckDLLs(const aFrameworkDirPath : string; var aMissingFiles : string) : boolean; function CheckDLLs(const aFrameworkDirPath : string; var aMissingFiles : string) : boolean;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
function CheckDLLVersion(const aDLLFile : string; aMajor, aMinor, aRelease, aBuild : uint16) : boolean; function CheckDLLVersion(const aDLLFile : ustring; aMajor, aMinor, aRelease, aBuild : uint16) : boolean;
function GetDLLHeaderMachine(const aDLLFile : string; var aMachine : integer) : boolean; function GetDLLHeaderMachine(const aDLLFile : ustring; var aMachine : integer) : boolean;
{$ENDIF} {$ENDIF}
function FileVersionInfoToString(const aVersionInfo : TFileVersionInfo) : string; function FileVersionInfoToString(const aVersionInfo : TFileVersionInfo) : string;
function CheckFilesExist(var aList : TStringList; var aMissingFiles : string) : boolean; function CheckFilesExist(var aList : TStringList; var aMissingFiles : string) : boolean;
@ -895,7 +896,7 @@ begin
{$IFDEF FMX} {$IFDEF FMX}
FMX.Types.Log.d(aMessage); FMX.Types.Log.d(aMessage);
{$ELSE} {$ELSE}
{$IFNDEF FPC} {$IFDEF MSWINDOWS}
OutputDebugString({$IFDEF DELPHI12_UP}PWideChar{$ELSE}PAnsiChar{$ENDIF}(aMessage + chr(0))); OutputDebugString({$IFDEF DELPHI12_UP}PWideChar{$ELSE}PAnsiChar{$ENDIF}(aMessage + chr(0)));
{$ENDIF} {$ENDIF}
{$ENDIF} {$ENDIF}
@ -1259,7 +1260,7 @@ begin
end; end;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
function GetExtendedFileVersion(const aFileName : string) : uint64; function GetExtendedFileVersion(const aFileName : ustring) : uint64;
var var
TempSize : DWORD; TempSize : DWORD;
TempBuffer : pointer; TempBuffer : pointer;
@ -1272,20 +1273,22 @@ begin
try try
try try
TempSize := GetFileVersioninfoSize(PChar(aFileName), TempHandle); TempSize := GetFileVersionInfoSizeW(PWideChar(aFileName), TempHandle);
if (TempSize > 0) then if (TempSize > 0) then
begin begin
GetMem(TempBuffer, TempSize); GetMem(TempBuffer, TempSize);
if GetFileVersionInfo(PChar(aFileName), TempHandle, TempSize, TempBuffer) and if GetFileVersionInfoW(PWideChar(aFileName), TempHandle, TempSize, TempBuffer) and
VerQueryValue(TempBuffer, '\', Pointer(TempInfo), TempLen) then VerQueryValue(TempBuffer, '\', Pointer(TempInfo), TempLen) then
begin begin
Result := TempInfo^.dwFileVersionMS; Result := TempInfo^.dwFileVersionMS;
Result := Result shl 32; Result := Result shl 32;
Result := Result or TempInfo^.dwFileVersionLS; Result := Result or TempInfo^.dwFileVersionLS;
end; end;
end; end
else
OutputLastErrorMessage;
except except
on e : exception do on e : exception do
if CustomExceptionHandler('GetExtendedFileVersion', e) then raise; if CustomExceptionHandler('GetExtendedFileVersion', e) then raise;
@ -1295,6 +1298,13 @@ begin
end; end;
end; end;
procedure OutputLastErrorMessage;
begin
{$IFDEF DEBUG}
OutputDebugString({$IFDEF DELPHI12_UP}PWideChar{$ELSE}PAnsiChar{$ENDIF}(SysErrorMessage(GetLastError()) + chr(0)));
{$ENDIF}
end;
function GetStringFileInfo(const aFileName, aField : string; var aValue : string) : boolean; function GetStringFileInfo(const aFileName, aField : string; var aValue : string) : boolean;
type type
PLangAndCodepage = ^TLangAndCodepage; PLangAndCodepage = ^TLangAndCodepage;
@ -1319,13 +1329,13 @@ begin
try try
try try
TempSize := GetFileVersionInfoSize(PChar(aFileName), TempHandle); TempSize := GetFileVersionInfoSizeW(PWideChar(aFileName), TempHandle);
if (TempSize > 0) then if (TempSize > 0) then
begin begin
GetMem(TempBuffer, TempSize); GetMem(TempBuffer, TempSize);
if GetFileVersionInfo(PChar(aFileName), 0, TempSize, TempBuffer) then if GetFileVersionInfoW(PWideChar(aFileName), 0, TempSize, TempBuffer) then
begin begin
if VerQueryValue(TempBuffer, '\VarFileInfo\Translation\', Pointer(TempLang), TempSize) then if VerQueryValue(TempBuffer, '\VarFileInfo\Translation\', Pointer(TempLang), TempSize) then
begin begin
@ -1352,7 +1362,7 @@ begin
IntToHex(TempArray[i].wLanguage, 4) + IntToHex(TempArray[i].wCodePage, 4) + IntToHex(TempArray[i].wLanguage, 4) + IntToHex(TempArray[i].wCodePage, 4) +
'\' + aField; '\' + aField;
if VerQueryValue(TempBuffer, PChar(TempSubBlock), TempPointer, TempSize) then if VerQueryValueW(TempBuffer, PWideChar(TempSubBlock), TempPointer, TempSize) then
begin begin
aValue := trim(PChar(TempPointer)); aValue := trim(PChar(TempPointer));
Result := (length(aValue) > 0); Result := (length(aValue) > 0);
@ -1368,7 +1378,7 @@ begin
IntToHex(TempArray[0].wLanguage, 4) + IntToHex(1252, 4) + IntToHex(TempArray[0].wLanguage, 4) + IntToHex(1252, 4) +
'\' + aField; '\' + aField;
if VerQueryValue(TempBuffer, PChar(TempSubBlock), TempPointer, TempSize) then if VerQueryValueW(TempBuffer, PWideChar(TempSubBlock), TempPointer, TempSize) then
begin begin
aValue := trim(PChar(TempPointer)); aValue := trim(PChar(TempPointer));
Result := (length(aValue) > 0); Result := (length(aValue) > 0);
@ -1385,7 +1395,7 @@ begin
end; end;
end; end;
function GetDLLVersion(const aDLLFile : string; var aVersionInfo : TFileVersionInfo) : boolean; function GetDLLVersion(const aDLLFile : ustring; var aVersionInfo : TFileVersionInfo) : boolean;
var var
TempVersion : uint64; TempVersion : uint64;
begin begin
@ -1395,26 +1405,19 @@ begin
if FileExists(aDLLFile) then if FileExists(aDLLFile) then
begin begin
TempVersion := GetExtendedFileVersion(aDLLFile); TempVersion := GetExtendedFileVersion(aDLLFile);
UInt64ToFileVersionInfo(TempVersion, aVersionInfo); if (TempVersion <> 0) then
Result := True; begin
UInt64ToFileVersionInfo(TempVersion, aVersionInfo);
Result := True;
end;
end; end;
except except
on e : exception do on e : exception do
if CustomExceptionHandler('GetDLLVersion', e) then raise; if CustomExceptionHandler('GetDLLVersion', e) then raise;
end; end;
end; end;
{$ENDIF}
function FileVersionInfoToString(const aVersionInfo : TFileVersionInfo) : string; function CheckDLLVersion(const aDLLFile : ustring; aMajor, aMinor, aRelease, aBuild : uint16) : boolean;
begin
Result := IntToStr(aVersionInfo.MajorVer) + '.' +
IntToStr(aVersionInfo.MinorVer) + '.' +
IntToStr(aVersionInfo.Release) + '.' +
IntToStr(aVersionInfo.Build);
end;
{$IFDEF MSWINDOWS}
function CheckDLLVersion(const aDLLFile : string; aMajor, aMinor, aRelease, aBuild : uint16) : boolean;
var var
TempVersionInfo : TFileVersionInfo; TempVersionInfo : TFileVersionInfo;
begin begin
@ -1427,7 +1430,7 @@ end;
// This function is based on the answer given by 'Alex' in StackOverflow // This function is based on the answer given by 'Alex' in StackOverflow
// https://stackoverflow.com/questions/2748474/how-to-determine-if-dll-file-was-compiled-as-x64-or-x86-bit-using-either-delphi // https://stackoverflow.com/questions/2748474/how-to-determine-if-dll-file-was-compiled-as-x64-or-x86-bit-using-either-delphi
function GetDLLHeaderMachine(const aDLLFile : string; var aMachine : integer) : boolean; function GetDLLHeaderMachine(const aDLLFile : ustring; var aMachine : integer) : boolean;
var var
TempHeader : TImageDosHeader; TempHeader : TImageDosHeader;
TempImageNtHeaders : TImageNtHeaders; TempImageNtHeaders : TImageNtHeaders;
@ -1468,6 +1471,14 @@ begin
end; end;
{$ENDIF} {$ENDIF}
function FileVersionInfoToString(const aVersionInfo : TFileVersionInfo) : string;
begin
Result := IntToStr(aVersionInfo.MajorVer) + '.' +
IntToStr(aVersionInfo.MinorVer) + '.' +
IntToStr(aVersionInfo.Release) + '.' +
IntToStr(aVersionInfo.Build);
end;
function Is32BitProcess : boolean; function Is32BitProcess : boolean;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
var var

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [ "UpdateLazPackages" : [
{ {
"ForceNotify" : true, "ForceNotify" : true,
"InternalVersion" : 142, "InternalVersion" : 143,
"Name" : "cef4delphi_lazarus.lpk", "Name" : "cef4delphi_lazarus.lpk",
"Version" : "83.3.12.0" "Version" : "83.3.12.0"
} }