AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte Delphi TRAFFIC V0.1
Thema durchsuchen
Ansicht
Themen-Optionen

TRAFFIC V0.1

Ein Thema von s4sh81 · begonnen am 30. Dez 2008 · letzter Beitrag vom 10. Jan 2009
 
s4sh81

Registriert seit: 11. Sep 2008
11 Beiträge
 
#1

TRAFFIC V0.1

  Alt 30. Dez 2008, 19:08
Stelle hier mal für alle einen kleinen Traffic Monitor Source online.
Hat einen kleinen Haken, da bei der Auswahl der Netzwerkkarte bei BytesIn und BytesOut ein hoher Wert zustande kommt.

Delphi-Quellcode:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Winsock, IpExport, IpHlpApi, IpTypes, IpIfConst, IpRtrMib,
  ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Label1: TLabel;
    Button1: TButton;
    Label2: TLabel;
    combobox1: TComboBox;
    Timer2: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  old: integer;
  old1 : integer;
  BytesIn, BytesOut :integer;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var MibRow: TMibIfRow;
IntfTable: PMibIfTable;
Size: DWORD;
I, J: Integer;
begin
  with combobox1 do begin
  if combobox1.itemindex = 0 then J := 0;
  if combobox1.itemindex = 1 then J := 1;
  if combobox1.itemindex = 2 then J := 2;
  if combobox1.itemindex = 3 then J := 3;
  if combobox1.itemindex = 4 then J := 4;
end;
//Auswahl der Netzwerkkarte

try
Size := 0;
if GetIfTable(nil, Size, True) <> ERROR_INSUFFICIENT_BUFFER then Exit;
IntfTable := AllocMem(Size);
try
if GetIfTable(IntfTable, Size, True) = NO_ERROR then
begin
for I := 0 to IntfTable^.dwNumEntries - 1 do
begin
{$R-}MibRow := IntfTable.Table[I];{$R+}
if MibRow.dwType <> MIB_IF_TYPE_ETHERNET then Continue; // oder MIB_IF_TYPE_PPP


if i = j then begin
BytesIn := MibRow.dwInOctets - old;
label1.caption := floattostr(round(BytesIn /1024 *100)/100) + ' KB/s';
old := MibRow.dwInOctets;

BytesOut := MibRow.dwOutOctets - old1;
label2.Caption := floattostr(round(BytesOut /1024 *100)/100) + ' KB/s';
old1 := MibRow.dwOutOctets;
end;
end;
end;
except
on erangeerror do
begin
timer1.Enabled:=false;
showmessage('Ein Treiberproblem ist aufgetreten! Starten Sie den Computer neu.');
end;
end;
finally
FreeMem(IntfTable);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;

procedure TForm1.FormCreate(Sender: TObject);
var MibRow: TMibIfRow;
    IntfTable: PMibIfTable;
    Size: DWORD;
    I : Integer;
begin
BytesIn := 0;
BytesOut := 0;
size := 0;
  if GetIfTable(nil, Size, True) <> ERROR_INSUFFICIENT_BUFFER then Exit;
  IntfTable := AllocMem(Size);
  try
    if GetIfTable(IntfTable, Size, True) = NO_ERROR then
    begin
    for I := 0 to IntfTable^.dwNumEntries - 1 do
      begin
      {$R-}MibRow := IntfTable.Table[I];{$R+}
      combobox1.items.Add(PChar(@MibRow.bDescr[0]) + ' @ ' + InttoStr(MibRow.dwSpeed div 1000000)+ ' MBit/s');
      end;
    end;
  finally
  FreeMem(IntfTable);
end;
end;

end.
Angehängte Dateien
Dateityp: exe traffic_104.exe (411,0 KB, 73x aufgerufen)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:25 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz