⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 控件特性:活动的RAS连接到INTERNET通知;断开INTERNET连接通知;RAS拨入设备完整状态信息及连接状态;返回PC系统的当地IP地址和主机名;返回拨号连接的RASClient分配的INTE
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  CPRasMonitor, StdCtrls, ShellAPI;

type
  TForm1 = class(TForm)
    RasMonitor1: TRasMonitor;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    GroupBox3: TGroupBox;
    EventLog: TMemo;
    bstart: TButton;
    bstop: TButton;
    brasinfo: TButton;
    bhangup: TButton;
    bclearlog: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    lab1: TLabel;
    lab2: TLabel;
    lmonitoring: TLabel;
    lconnection: TLabel;
    lrasconnid: TLabel;
    ldialupname: TLabel;
    ldevicetype: TLabel;
    ldevicename: TLabel;
    lrasclientip: TLabel;
    lrasclienthost: TLabel;
    lrasserverip: TLabel;
    lrasserverhost: TLabel;
    lstatus: TLabel;
    llocalip: TLabel;
    llocalhost: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    binformation: TButton;
    procedure bstartClick(Sender: TObject);
    procedure bstopClick(Sender: TObject);
    procedure brasinfoClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure bhangupClick(Sender: TObject);
    procedure bclearlogClick(Sender: TObject);
    procedure RasMonitor1RasConnected(Sender: TObject;
      ConnectionDetails: TRasConnectionDetails);
    procedure RasMonitor1RasDisconnected(Sender: TObject;
      ConnectionDetails: TRasConnectionDetails);
    procedure RasMonitor1RasStatusChanged(Sender: TObject;
      ConnectionDetails: TRasConnectionDetails; StatusStr: String);
    procedure Label14Click(Sender: TObject);
    procedure binformationClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const
APP_PAGE = 'http://www.bitlogic.co.uk';
SRC_PAGE = 'https://secure.element5.com/register.html?productid=142889&language=English';
EMAIL_ADD = 'mailto:components@bitlogic.co.uk?subject=RasMonitor Source';

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.bstartClick(Sender: TObject);
begin
RasMonitor1.Enabled := True;
bstart.Enabled := Not RasMonitor1.Enabled;
bstop.Enabled := RasMonitor1.Enabled;
if RasMonitor1.Enabled then lmonitoring.Caption := 'Enabled'
else lmonitoring.Caption := 'Disabled';
Eventlog.Lines.Add('RasMonitor Enabled, now monitoring..');
end;

procedure TForm1.bstopClick(Sender: TObject);
begin
RasMonitor1.Enabled := False;
bstart.Enabled := Not RasMonitor1.Enabled;
bstop.Enabled := RasMonitor1.Enabled;
if RasMonitor1.Enabled then lmonitoring.Caption := 'Enabled'
else lmonitoring.Caption := 'Disabled';
Eventlog.Lines.Add('RasMonitor Disabled');
end;

procedure TForm1.brasinfoClick(Sender: TObject);
var
ConnDetails: TRasConnectionDetails;
begin
if RasMonitor1.GetRasConnection(ConnDetails) then lconnection.Caption := 'ONLINE'
else lconnection.Caption := 'OFFLINE ';
lrasconnid.Caption := inttostr(ConnDetails.RasConn);
lstatus.caption := ConnDetails.ConnStatus;
ldialupname.caption := ConnDetails.ConnName;
ldevicetype.caption := ConnDetails.ConnDeviceType;
ldevicename.caption := ConnDetails.ConnDeviceName;
lrasclientip.caption := ConnDetails.ConnClientIP;
lrasclienthost.Caption := RasMonitor1.WSGetHostByAddr(Conndetails.ConnClientIP);
lrasserverip.caption := Conndetails.ConnServerIP;
lrasserverhost.Caption := RasMonitor1.WSGetHostByAddr(Conndetails.ConnServerIP);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
if RasMonitor1.RasApiLoaded then Eventlog.Lines.Add('RASAPI Loaded, component ready..')
else Eventlog.Lines.Add('RASAPI Failed, component non functional !');
if RasMonitor1.Online then lconnection.Caption := 'ONLINE'
else lconnection.Caption := 'OFFLINE';
if RasMonitor1.Enabled then lmonitoring.Caption := 'Enabled'
else lmonitoring.Caption := 'Disabled';
lrasconnid.Caption := inttostr(RasMonitor1.ConnectionDetails.RasConn);
lstatus.Caption := RasMonitor1.ConnectionDetails.ConnStatus;
ldialupname.Caption := RasMonitor1.ConnectionDetails.ConnName;
ldevicetype.Caption := RasMonitor1.ConnectionDetails.ConnDeviceType;
ldevicename.Caption := RasMonitor1.ConnectionDetails.ConnDeviceName;
lrasclientip.Caption := RasMonitor1.ConnectionDetails.ConnClientIP;
lrasclienthost.Caption := RasMonitor1.WSGetHostByAddr(RasMonitor1.ConnectionDetails.ConnClientIP);
lrasserverip.Caption := RasMonitor1.ConnectionDetails.ConnServerIP;
lrasserverhost.Caption := RasMonitor1.WSGetHostByAddr(RasMonitor1.ConnectionDetails.ConnServerIP);
llocalip.Caption := RasMonitor1.LocalIP;
llocalhost.Caption := RasMonitor1.LocalHost;
end;

procedure TForm1.bhangupClick(Sender: TObject);
begin
RasMonitor1.HangUpRasConnection(RasMonitor1.ConnectionDetails.RasConn);
if Not RasMonitor1.Online then lconnection.Caption := 'OFFLINE';
end;

procedure TForm1.bclearlogClick(Sender: TObject);
begin
EventLog.Lines.Clear;
end;

procedure TForm1.RasMonitor1RasConnected(Sender: TObject;
  ConnectionDetails: TRasConnectionDetails);
begin
Eventlog.Lines.Add('RAS Connected, Online');
if RasMonitor1.Online then lconnection.Caption := 'ONLINE';
lrasconnid.Caption := inttostr(ConnectionDetails.RasConn);
lstatus.Caption := ConnectionDetails.ConnStatus;
ldialupname.Caption := ConnectionDetails.ConnName;
ldevicetype.Caption := ConnectionDetails.ConnDeviceType;
ldevicename.Caption := ConnectionDetails.ConnDeviceName;
lrasclientip.Caption := ConnectionDetails.ConnClientIP;
lrasclienthost.Caption := RasMonitor1.WSGetHostByAddr(RasMonitor1.ConnectionDetails.ConnClientIP);
lrasserverip.Caption := ConnectionDetails.ConnServerIP;
lrasserverhost.Caption := RasMonitor1.WSGetHostByAddr(RasMonitor1.ConnectionDetails.ConnServerIP);
end;

procedure TForm1.RasMonitor1RasDisconnected(Sender: TObject;
  ConnectionDetails: TRasConnectionDetails);
begin
Eventlog.Lines.Add('RAS Disconnected, Offline');
if Not RasMonitor1.Online then lconnection.Caption := 'OFFLINE';
lrasconnid.Caption := inttostr(ConnectionDetails.RasConn);
lstatus.Caption := ConnectionDetails.ConnStatus;
ldialupname.Caption := ConnectionDetails.ConnName;
ldevicetype.Caption := ConnectionDetails.ConnDeviceType;
ldevicename.Caption := ConnectionDetails.ConnDeviceName;
lrasclientip.Caption := ConnectionDetails.ConnClientIP;
lrasclienthost.Caption := RasMonitor1.WSGetHostByAddr(RasMonitor1.ConnectionDetails.ConnClientIP);
lrasserverip.Caption := ConnectionDetails.ConnServerIP;
lrasserverhost.Caption := RasMonitor1.WSGetHostByAddr(RasMonitor1.ConnectionDetails.ConnServerIP);
end;

procedure TForm1.RasMonitor1RasStatusChanged(Sender: TObject;
  ConnectionDetails: TRasConnectionDetails; StatusStr: String);
begin
Eventlog.Lines.Add('RAS StatusChanged, '+StatusStr);
if Not RasMonitor1.Online then lconnection.Caption := 'OFFLINE'
else lconnection.Caption := 'ONLINE';
end;

procedure TForm1.Label14Click(Sender: TObject);
begin
ShellExecute(GetDesktopWindow(), 'open', PChar(SRC_PAGE), nil, nil, SW_SHOWNORMAL);
end;

procedure TForm1.binformationClick(Sender: TObject);
begin
MessageDlg(' ず癭昂

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -