unit libUtilsNetworkU; { 18.05.2005 - PhP - unit created } interface function GetDownloadSpeed(Raw: boolean): string; function GetDownloadTotal: string; function GetUploadSpeed(Raw: boolean): string; function GetUploadTotal: string; implementation uses Classes, SysUtils, IpRtrMib, IpFunctions, libUtilsU; var g_iNetDownBytes: int64 = 0; g_iNetDownBytesOld: int64 = 0; g_iNetUpBytes: int64 = 0; g_iNetUpBytesOld: int64 = 0; { @name GetNetDownBytes @return int64 @author PhP @date 17.04.2001 ( 18.05.2005) @version 2 } function GetNetDownBytes: int64; var xMibIfTable: PMibIfTable; iSize: cardinal; iIndex: integer; begin VVGetIfTable(xMibIfTable, iSize, True); Result := 0; if xMibIfTable <> nil then begin for iIndex := 0 to xMibIfTable^.dwNumEntries - 1 do Result := Result + xMibIfTable^.Table[iIndex].dwInOctets; FreeMem(xMibIfTable, iSize); end; end; { @name GetNetUpBytes @return int64 @author PhP @date 17.04.2001 (18.05.2005) @version 2 } function GetNetUpBytes: int64; var xMibIfTable: PMibIfTable; iSize: cardinal; iIndex: integer; begin VVGetIfTable(xMibIfTable, iSize, True); Result := 0; if xMibIfTable <> nil then begin for iIndex := 0 to xMibIfTable^.dwNumEntries - 1 do Result := Result + xMibIfTable^.Table[iIndex].dwOutOctets; FreeMem(xMibIfTable, iSize); end; end; { @name GetDownloadSpeed @param Raw boolean @return string @author PhP @date 18.05.2005 (19.05.2005) @version 2 } function GetDownloadSpeed(Raw: boolean): string; begin g_iNetDownBytes := GetNetDownBytes; if Raw then Result := IntToStr(g_iNetDownBytes - g_iNetDownBytesOld) else Result := BytesToString(g_iNetDownBytes - g_iNetDownBytesOld); g_iNetDownBytesOld := g_iNetDownBytes; end; { @name GetDownloadTotal @return string @author PhP @date 18.05.2005 @version 1 } function GetDownloadTotal: string; begin Result := BytesToString(GetNetDownBytes); end; { @name GetUploadSpeed @param Raw boolean @return string @author PhP @date 18.05.2005 (19.05.2005) @version 2 } function GetUploadSpeed(Raw: boolean): string; begin g_iNetUpBytes := GetNetUpBytes; if Raw then Result := IntToStr(g_iNetUpBytes - g_iNetUpBytesOld) else Result := BytesToString(g_iNetUpBytes - g_iNetUpBytesOld); g_iNetUpBytesOld := g_iNetUpBytes; end; { @name GetUploadTotal @return string @author PhP @date 18.05.2005 @version 1 } function GetUploadTotal: string; begin Result := BytesToString(GetNetUpBytes); end; end.