1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-02-02 10:25:26 +02:00

Added memory information properties to GlobalCEFApp

This commit is contained in:
Salvador Díaz Fau 2018-10-25 12:50:01 +02:00
parent b5920d1aac
commit 139f1dded2
12 changed files with 351 additions and 49 deletions

View File

@ -34,6 +34,12 @@
<Cfg_1>true</Cfg_1>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win64)'!=''">
<Cfg_1_Win64>true</Cfg_1_Win64>
<CfgParent>Cfg_1</CfgParent>
<Cfg_1>true</Cfg_1>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
@ -45,6 +51,12 @@
<Cfg_2>true</Cfg_2>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win64)'!=''">
<Cfg_2_Win64>true</Cfg_2_Win64>
<CfgParent>Cfg_2</CfgParent>
<Cfg_2>true</Cfg_2>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
<DCC_E>false</DCC_E>
@ -60,6 +72,7 @@
<VerInfo_Locale>3082</VerInfo_Locale>
<SanitizedProjectName>CookieVisitor</SanitizedProjectName>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<DCC_ExeOutput>..\..\bin</DCC_ExeOutput>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_UsePackage>DBXSqliteDriver;bindcompdbx;fmxase;DBXDb2Driver;DBXInterBaseDriver;vcl;DBXSybaseASEDriver;vclactnband;vclFireDAC;FireDACDb2Driver;GR32_DSGN_RSXE5;DataSnapFireDAC;svnui;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;DBXMSSQLDriver;vclimg;FireDACInfxDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;FireDACPgDriver;DBXOracleDriver;inetdb;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;CEF4Delphi;DbxCommonDriver;IndyProtocols240;IndySystem240;fmx;DataSnapServer;xmlrtl;DataSnapNativeClient;fmxobj;fmxdae;vclwinx;rtl;FireDACDSDriver;DbxClientDriver;IndyCore240;DBXSybaseASADriver;CustomIPTransport;vcldsnap;dbexpress;FireDACDBXDriver;vclx;GR32_RSXE5;bindcomp;appanalytics;dsnap;DataSnapCommon;DBXInformixDriver;bindcompvcl;DataSnapConnectors;VCLRESTComponents;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;vclie;bindengine;DBXMySQLDriver;FireDACOracleDriver;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;DBXFirebirdDriver;DataSnapProviderClient;FireDACMongoDBDriver;FireDACCommonODBC;DataSnapClient;DataSnapServerMidas;$(DCC_UsePackage)</DCC_UsePackage>
@ -72,6 +85,11 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win64)'!=''">
<DCC_UsePackage>DBXSqliteDriver;bindcompdbx;fmxase;DBXDb2Driver;DBXInterBaseDriver;vcl;DBXSybaseASEDriver;vclactnband;vclFireDAC;FireDACDb2Driver;DataSnapFireDAC;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;DBXMSSQLDriver;vclimg;FireDACInfxDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;FireDACPgDriver;DBXOracleDriver;inetdb;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;DbxCommonDriver;IndyProtocols240;IndySystem240;fmx;DataSnapServer;xmlrtl;DataSnapNativeClient;fmxobj;fmxdae;vclwinx;rtl;FireDACDSDriver;DbxClientDriver;IndyCore240;DBXSybaseASADriver;CustomIPTransport;vcldsnap;dbexpress;FireDACDBXDriver;vclx;bindcomp;appanalytics;dsnap;DataSnapCommon;DBXInformixDriver;bindcompvcl;DataSnapConnectors;VCLRESTComponents;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;vclie;bindengine;DBXMySQLDriver;FireDACOracleDriver;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;DBXFirebirdDriver;DataSnapProviderClient;FireDACMongoDBDriver;FireDACCommonODBC;DataSnapClient;DataSnapServerMidas;$(DCC_UsePackage)</DCC_UsePackage>
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
<BT_BuildType>Debug</BT_BuildType>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale>
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
@ -88,6 +106,12 @@
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppEnableHighDPI>true</AppEnableHighDPI>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
@ -98,6 +122,10 @@
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppEnableHighDPI>true</AppEnableHighDPI>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppEnableHighDPI>true</AppEnableHighDPI>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource>

View File

@ -126,7 +126,7 @@ implementation
{$R *.dfm}
uses
uSimpleTextViewer;
uSimpleTextViewer, uCEFTask, uCEFMiscFunctions;
// This demo has a context menu to test the DeleteCookies function and a CookieVisitor example.

View File

@ -38,7 +38,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
BevelOuter = bvNone
Enabled = False
ShowCaption = False
TabOrder = 0
TabOrder = 1
object NavButtonPnl: TPanel
Left = 0
Top = 0
@ -221,7 +221,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
Height = 652
Align = alClient
TabStop = True
TabOrder = 1
TabOrder = 0
end
object DevTools: TCEFWindowParent
Left = 1184
@ -337,6 +337,13 @@ object MiniBrowserFrm: TMiniBrowserFrm
Caption = 'Resolve host...'
OnClick = Resolvehost1Click
end
object N5: TMenuItem
Caption = '-'
end
object Memoryinfo1: TMenuItem
Caption = 'Memory info...'
OnClick = Memoryinfo1Click
end
end
object SaveDialog1: TSaveDialog
Left = 32

View File

@ -116,6 +116,8 @@ type
Resolvehost1: TMenuItem;
Timer1: TTimer;
OpenfilewithaDAT1: TMenuItem;
N5: TMenuItem;
Memoryinfo1: TMenuItem;
procedure FormShow(Sender: TObject);
procedure BackBtnClick(Sender: TObject);
procedure ForwardBtnClick(Sender: TObject);
@ -198,6 +200,7 @@ type
procedure OpenfilewithaDAT1Click(Sender: TObject);
procedure Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser;
const frame: ICefFrame; httpStatusCode: Integer);
procedure Memoryinfo1Click(Sender: TObject);
protected
FResponse : TStringList;
@ -741,6 +744,20 @@ begin
end;
end;
procedure TMiniBrowserFrm.Memoryinfo1Click(Sender: TObject);
const
BYTES_PER_MEGABYTE = 1024 * 1024;
var
TempMessage : string;
begin
TempMessage := 'Total memory used by this application : ' + inttostr(GlobalCEFApp.UsedMemory div BYTES_PER_MEGABYTE) + ' Mb' + CRLF +
'Total system memory : ' + inttostr(GlobalCEFApp.TotalSystemMemory div BYTES_PER_MEGABYTE) + ' Mb' + CRLF +
'Available physical memory : ' + inttostr(GlobalCEFApp.AvailableSystemMemory div BYTES_PER_MEGABYTE) + ' Mb' + CRLF +
'Memory load : ' + inttostr(GlobalCEFApp.SystemMemoryLoad) + ' %';
MessageDlg(TempMessage, mtInformation, [mbOK], 0);
end;
procedure TMiniBrowserFrm.Chromium1ResourceResponse(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse;

View File

@ -47,7 +47,7 @@ uses
Forms,
Windows,
{$ENDIF }
uCEFApplication,
uCEFApplication, uCEFConstants,
uSimpleBrowser2 in 'uSimpleBrowser2.pas' {Form1};
{$R *.res}

View File

@ -103,7 +103,7 @@ implementation
{$R *.dfm}
uses
uCEFApplication;
uCEFApplication, uCefMiscFunctions;
// This is a demo with the simplest web browser you can build using CEF4Delphi and
// it doesn't show any sign of progress like other web browsers do.
@ -141,6 +141,7 @@ procedure TForm1.FormCreate(Sender: TObject);
begin
FCanClose := False;
FClosing := False;
Chromium1.DefaultURL := AddressEdt.Text;
end;
procedure TForm1.FormShow(Sender: TObject);
@ -190,7 +191,6 @@ procedure TForm1.BrowserCreatedMsg(var aMessage : TMessage);
begin
Caption := 'Simple Browser 2';
AddressPnl.Enabled := True;
GoBtn.Click;
end;
procedure TForm1.BrowserDestroyMsg(var aMessage : TMessage);

View File

@ -4,14 +4,14 @@
<PathDelim Value="\"/>
<Version Value="10"/>
<BuildModes Active="Default"/>
<Units Count="38">
<Units Count="45">
<Unit0>
<Filename Value="SimpleLazarusBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="5"/>
<CursorPos X="43" Y="5"/>
<UsageCount Value="38"/>
<UsageCount Value="39"/>
</Unit0>
<Unit1>
<Filename Value="usimplelazarusbrowser.pas"/>
@ -22,9 +22,9 @@
<UnitName Value="uSimpleLazarusBrowser"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="73"/>
<CursorPos X="53" Y="69"/>
<UsageCount Value="38"/>
<TopLine Value="43"/>
<CursorPos X="24" Y="68"/>
<UsageCount Value="39"/>
</Unit1>
<Unit2>
<Filename Value="..\..\source\uCEFChromium.pas"/>
@ -132,21 +132,21 @@
<Unit16>
<Filename Value="..\..\source\uCEFInterfaces.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="367"/>
<CursorPos X="14" Y="382"/>
<TopLine Value="165"/>
<CursorPos X="3" Y="183"/>
<UsageCount Value="12"/>
</Unit16>
<Unit17>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="2169"/>
<CursorPos Y="44"/>
<IsVisibleTab Value="True"/>
<TopLine Value="1633"/>
<CursorPos X="53" Y="1656"/>
<UsageCount Value="13"/>
<Bookmarks Count="2">
<Item0 X="60" Y="956" ID="1"/>
<Item1 X="9" Y="894" ID="3"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit17>
<Unit18>
<Filename Value="C:\lazarus\lcl\forms.pp"/>
@ -225,17 +225,18 @@
</Unit27>
<Unit28>
<Filename Value="..\..\source\uCEFTypes.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="235"/>
<CursorPos X="34" Y="252"/>
<EditorIndex Value="2"/>
<TopLine Value="538"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit28>
<Unit29>
<Filename Value="..\..\source\uCEFMiscFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="996"/>
<CursorPos X="67" Y="1003"/>
<EditorIndex Value="1"/>
<TopLine Value="99"/>
<CursorPos X="36" Y="131"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit29>
<Unit30>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\inc\ctypes.pp"/>
@ -274,38 +275,160 @@
</Unit34>
<Unit35>
<Filename Value="..\..\source\uCEFLinkedWindowParent.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="31"/>
<CursorPos X="28" Y="38"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit35>
<Unit36>
<Filename Value="..\..\source\uCEFWriteHandler.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<EditorIndex Value="-1"/>
<TopLine Value="336"/>
<CursorPos Y="358"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit36>
<Unit37>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\objpas\math.pp"/>
<EditorIndex Value="2"/>
<EditorIndex Value="-1"/>
<TopLine Value="158"/>
<CursorPos X="10" Y="180"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit37>
<Unit38>
<Filename Value="..\..\source\uCEFTask.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="109"/>
<CursorPos X="19" Y="82"/>
<UsageCount Value="10"/>
</Unit38>
<Unit39>
<Filename Value="..\..\source\uCEFCookieManager.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="123"/>
<CursorPos X="73" Y="139"/>
<UsageCount Value="10"/>
</Unit39>
<Unit40>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\objpas\sysutils\filutilh.inc"/>
<EditorIndex Value="7"/>
<TopLine Value="49"/>
<CursorPos X="3" Y="62"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit40>
<Unit41>
<Filename Value="C:\lazarus\fpc\3.0.4\source\packages\winunits-jedi\src\jwawindows.pas"/>
<UnitName Value="JwaWindows"/>
<EditorIndex Value="6"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit41>
<Unit42>
<Filename Value="C:\lazarus\fpc\3.0.4\source\packages\winunits-jedi\src\jwapsapi.pas"/>
<EditorIndex Value="5"/>
<TopLine Value="200"/>
<CursorPos X="10" Y="212"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit42>
<Unit43>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\win\wininc\redef.inc"/>
<EditorIndex Value="3"/>
<TopLine Value="636"/>
<CursorPos X="48" Y="649"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit43>
<Unit44>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\win\wininc\struct.inc"/>
<EditorIndex Value="4"/>
<TopLine Value="4666"/>
<CursorPos X="6" Y="4679"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit44>
</Units>
<JumpHistory Count="2" HistoryIndex="1">
<JumpHistory Count="20" HistoryIndex="19">
<Position1>
<Filename Value="..\..\source\uCEFLinkedWindowParent.pas"/>
<Caret Line="38" Column="28" TopLine="31"/>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="445" Column="58" TopLine="427"/>
</Position1>
<Position2>
<Filename Value="..\..\source\uCEFWriteHandler.pas"/>
<Caret Line="353" Column="19" TopLine="321"/>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1190" Column="17" TopLine="1173"/>
</Position2>
<Position3>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="447" Column="51" TopLine="428"/>
</Position3>
<Position4>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1182" Column="72" TopLine="1160"/>
</Position4>
<Position5>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1190" Column="39" TopLine="1121"/>
</Position5>
<Position6>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1571" Column="46" TopLine="1556"/>
</Position6>
<Position7>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1190" Column="64" TopLine="1165"/>
</Position7>
<Position8>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="447" Column="38" TopLine="439"/>
</Position8>
<Position9>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1190" Column="20" TopLine="436"/>
</Position9>
<Position10>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\objpas\sysutils\filutilh.inc"/>
<Caret Line="165" Column="60" TopLine="154"/>
</Position10>
<Position11>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1196" Column="49" TopLine="1162"/>
</Position11>
<Position12>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\objpas\sysutils\filutilh.inc"/>
<Caret Line="80" Column="3" TopLine="67"/>
</Position12>
<Position13>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\objpas\sysutils\filutilh.inc"/>
<Caret Line="62" Column="3" TopLine="49"/>
</Position13>
<Position14>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="447" Column="46" TopLine="424"/>
</Position14>
<Position15>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1599" Column="55" TopLine="1587"/>
</Position15>
<Position16>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1620" Column="73" TopLine="1604"/>
</Position16>
<Position17>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\win\wininc\redef.inc"/>
<Caret Line="649" Column="48" TopLine="636"/>
</Position17>
<Position18>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<Caret Line="1618" Column="62" TopLine="1604"/>
</Position18>
<Position19>
<Filename Value="..\..\source\uCEFMiscFunctions.pas"/>
<Caret Line="132" Column="48" TopLine="51"/>
</Position19>
<Position20>
<Filename Value="..\..\source\uCEFMiscFunctions.pas"/>
<Caret Line="131" Column="36" TopLine="99"/>
</Position20>
</JumpHistory>
</ProjectSession>
</CONFIG>

View File

@ -10,7 +10,7 @@ object Form1: TForm1
OnCreate = FormCreate
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.8.2.0'
LCLVersion = '1.8.4.0'
object AddressPnl: TPanel
Left = 0
Height = 23

View File

@ -47,9 +47,7 @@ uses
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFChromiumEvents;
type
{ TForm1 }
TForm1 = class(TForm)
CEFWindowParent1: TCEFWindowParent;
Chromium1: TChromium;

View File

@ -196,6 +196,10 @@ type
function GetMustCreateRenderProcessHandler : boolean;
function GetGlobalContextInitialized : boolean;
function GetChildProcessesCount : integer;
function GetUsedMemory : cardinal;
function GetTotalSystemMemory : uint64;
function GetAvailableSystemMemory : uint64;
function GetSystemMemoryLoad : cardinal;
function LoadCEFlibrary : boolean; virtual;
function Load_cef_app_capi_h : boolean;
@ -373,6 +377,10 @@ type
property MustFreeLibrary : boolean read FMustFreeLibrary write FMustFreeLibrary;
property AutoplayPolicy : TCefAutoplayPolicy read FAutoplayPolicy write FAutoplayPolicy;
property ChildProcessesCount : integer read GetChildProcessesCount;
property UsedMemory : cardinal read GetUsedMemory;
property TotalSystemMemory : uint64 read GetTotalSystemMemory;
property AvailableSystemMemory : uint64 read GetAvailableSystemMemory;
property SystemMemoryLoad : cardinal read GetSystemMemoryLoad;
property OnRegCustomSchemes : TOnRegisterCustomSchemesEvent read FOnRegisterCustomSchemes write FOnRegisterCustomSchemes;
@ -432,13 +440,13 @@ implementation
uses
{$IFDEF DELPHI16_UP}
System.Math, System.IOUtils, System.SysUtils, {$IFDEF MSWINDOWS}WinApi.TlHelp32,{$ENDIF}
System.Math, System.IOUtils, System.SysUtils, {$IFDEF MSWINDOWS}WinApi.TlHelp32, PSAPI,{$ENDIF}
{$ELSE}
Math, {$IFDEF DELPHI14_UP}IOUtils,{$ENDIF} SysUtils,
{$IFDEF FPC}
{$IFDEF MSWINDOWS}jwatlhelp32,{$ENDIF}
{$IFDEF MSWINDOWS}jwatlhelp32, jwapsapi,{$ENDIF}
{$ELSE}
TlHelp32,
TlHelp32, {$IFDEF MSWINDOWS}PSAPI,{$ENDIF}
{$ENDIF}
{$ENDIF}
uCEFLibFunctions, uCEFMiscFunctions, uCEFCommandLine, uCEFConstants,
@ -1519,7 +1527,10 @@ begin
Result := 0;
{$IFDEF MSWINDOWS}
TempHandle := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
TempHandle := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
if (TempHandle = INVALID_HANDLE_VALUE) then exit;
ZeroMemory(@TempProcess, SizeOf(TProcessEntry32));
TempProcess.dwSize := Sizeof(TProcessEntry32);
TempPID := GetCurrentProcessID;
TempMain := ExtractFileName(paramstr(0));
@ -1544,6 +1555,109 @@ begin
{$ENDIF}
end;
function TCefApplication.GetUsedMemory : cardinal;
{$IFDEF MSWINDOWS}
var
TempHandle : THandle;
TempProcess : TProcessEntry32;
TempPID : DWORD;
TempProcHWND : HWND;
TempMemCtrs : TProcessMemoryCounters;
TempMain, TempSubProc, TempName : string;
{$ENDIF}
begin
Result := 0;
{$IFDEF MSWINDOWS}
TempHandle := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
if (TempHandle = INVALID_HANDLE_VALUE) then exit;
ZeroMemory(@TempProcess, SizeOf(TProcessEntry32));
TempProcess.dwSize := Sizeof(TProcessEntry32);
TempPID := GetCurrentProcessID;
TempMain := ExtractFileName(paramstr(0));
TempSubProc := ExtractFileName(FBrowserSubprocessPath);
Process32First(TempHandle, TempProcess);
repeat
if (TempProcess.th32ProcessID = TempPID) or
(TempProcess.th32ParentProcessID = TempPID) then
begin
TempName := TempProcess.szExeFile;
TempName := ExtractFileName(TempName);
if (CompareText(TempName, TempMain) = 0) or
((length(TempSubProc) > 0) and (CompareText(TempName, TempSubProc) = 0)) then
begin
TempProcHWND := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, TempProcess.th32ProcessID);
if (TempProcHWND <> 0) then
begin
ZeroMemory(@TempMemCtrs, SizeOf(TProcessMemoryCounters));
TempMemCtrs.cb := SizeOf(TProcessMemoryCounters);
{$IFDEF FPC}
if GetProcessMemoryInfo(TempProcHWND, TempMemCtrs, TempMemCtrs.cb) then inc(Result, TempMemCtrs.WorkingSetSize);
{$ELSE}
if GetProcessMemoryInfo(TempProcHWND, @TempMemCtrs, TempMemCtrs.cb) then inc(Result, TempMemCtrs.WorkingSetSize);
{$ENDIF}
CloseHandle(TempProcHWND);
end;
end;
end;
until not(Process32Next(TempHandle, TempProcess));
CloseHandle(TempHandle);
{$ENDIF}
end;
function TCefApplication.GetTotalSystemMemory : uint64;
{$IFDEF MSWINDOWS}
var
TempMemStatus : TMyMemoryStatusEx;
{$ENDIF}
begin
Result := 0;
{$IFDEF MSWINDOWS}
ZeroMemory(@TempMemStatus, SizeOf(TMyMemoryStatusEx));
TempMemStatus.dwLength := SizeOf(TMyMemoryStatusEx);
if GetGlobalMemoryStatusEx(TempMemStatus) then Result := TempMemStatus.ullTotalPhys;
{$ENDIF}
end;
function TCefApplication.GetAvailableSystemMemory : uint64;
{$IFDEF MSWINDOWS}
var
TempMemStatus : TMyMemoryStatusEx;
{$ENDIF}
begin
Result := 0;
{$IFDEF MSWINDOWS}
ZeroMemory(@TempMemStatus, SizeOf(TMyMemoryStatusEx));
TempMemStatus.dwLength := SizeOf(TMyMemoryStatusEx);
if GetGlobalMemoryStatusEx(TempMemStatus) then Result := TempMemStatus.ullAvailPhys;
{$ENDIF}
end;
function TCefApplication.GetSystemMemoryLoad : cardinal;
{$IFDEF MSWINDOWS}
var
TempMemStatus : TMyMemoryStatusEx;
{$ENDIF}
begin
Result := 0;
{$IFDEF MSWINDOWS}
ZeroMemory(@TempMemStatus, SizeOf(TMyMemoryStatusEx));
TempMemStatus.dwLength := SizeOf(TMyMemoryStatusEx);
if GetGlobalMemoryStatusEx(TempMemStatus) then Result := TempMemStatus.dwMemoryLoad;
{$ENDIF}
end;
function TCefApplication.LoadCEFlibrary : boolean;
var
TempOldDir, TempString : string;

View File

@ -127,6 +127,7 @@ function SystemTimeToTzSpecificLocalTime(lpTimeZoneInformation: PTimeZoneInforma
function PathIsRelativeAnsi(pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeA';
function PathIsRelativeUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeW';
function GetGlobalMemoryStatusEx(var Buffer: TMyMemoryStatusEx): BOOL; stdcall; external Kernel32DLL name 'GlobalMemoryStatusEx';
{$IFNDEF DELPHI12_UP}
{$IFDEF WIN64}
@ -422,11 +423,11 @@ var
TempTime : TSystemTime;
begin
Result := 0;
try
TempTime := CefTimeToSystemTime(dt);
try
TempTime := CefTimeToSystemTime(dt);
SystemTimeToTzSpecificLocalTime(nil, @TempTime, @TempTime);
Result := SystemTimeToDateTime(TempTime);
Result := SystemTimeToDateTime(TempTime);
except
on e : exception do
if CustomExceptionHandler('CefTimeToDateTime', e) then raise;
@ -438,11 +439,11 @@ var
TempTime : TSystemTime;
begin
FillChar(Result, SizeOf(TCefTime), 0);
try
DateTimeToSystemTime(dt, TempTime);
try
DateTimeToSystemTime(dt, TempTime);
TzSpecificLocalTimeToSystemTime(nil, @TempTime, @TempTime);
Result := SystemTimeToCefTime(TempTime);
Result := SystemTimeToCefTime(TempTime);
except
on e : exception do
if CustomExceptionHandler('DateTimeToCefTime', e) then raise;

View File

@ -2953,6 +2953,20 @@ type
on_key_event : function(self: PCefWindowDelegate; window: PCefWindow; const event: PCefKeyEvent): Integer; stdcall;
end;
{$IFDEF MSWINDOWS}
TMyMemoryStatusEx = record
dwLength : DWORD;
dwMemoryLoad : DWORD;
ullTotalPhys : uint64;
ullAvailPhys : uint64;
ullTotalPageFile : uint64;
ullAvailPageFile : uint64;
ullTotalVirtual : uint64;
ullAvailVirtual : uint64;
ullAvailExtendedVirtual : uint64;
end;
{$ENDIF}
implementation
end.