NetInfoDlg.pas
上传用户:hbtcygglw
上传日期:2007-01-07
资源大小:281k
文件大小:3k
- unit NetInfoDlg;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls,nb30, Menus;
- type
- TNetBiosInfoDlg = class(TForm)
- Label1: TLabel;
- edHostAddr: TEdit;
- GroupBox1: TGroupBox;
- btnExecute: TButton;
- InfoList: TListBox;
- InfoMenu: TPopupMenu;
- mSave: TMenuItem;
- mClear: TMenuItem;
- btnClose: TButton;
- SaveDlg: TSaveDialog;
- procedure btnExecuteClick(Sender: TObject);
- procedure mClearClick(Sender: TObject);
- procedure mSaveClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- class procedure Execute(ip:string);
- end;
- implementation
- {$R *.DFM}
- uses NetBEUI,info;
- { TNetBiosInfoDlg }
- class procedure TNetBiosInfoDlg.Execute(ip: string);
- begin
- with TNetBiosInfoDlg.Create(Application) do
- begin
- edHostAddr.Text:=ip;
- ShowModal;
- Free;
- end;
- end;
- procedure TNetBiosInfoDlg.btnExecuteClick(Sender: TObject);
- var
- inf:TNetBEUI;
- list:TList;
- i:Integer;
- p:PNameBuffer;
- n,t,s:string;
- begin
- InfoList.Clear;
- inf:=TNetBEUI.Create(self);
- if(inf.GetNetBiosStatus(edHostAddr.Text))then
- begin
- InfoList.Items.Add('目标 主机 名:'+inf.GetRemoteHostName);
- InfoList.Items.Add('目标网卡地址:'+inf.GetMACAddr);
- case Inf.GetAdapterType of
- DIALUP:InfoList.Items.Add('目标上网方式:拨号上网');
- ETHERNET:InfoList.Items.Add('目标上网方式:局域网接入');
- else InfoList.Items.Add('目标上网方式:未知');
- end;
- InfoList.Items.Add('NetBIOS 名字列表:');
- InfoList.Items.Add('Name Type Status');
- InfoList.Items.Add('-----------------------------------');
- list:=Inf.GetNetBiosNameList;
- for i:=0 to list.Count-1 do
- begin
- p:=PNameBuffer(list.Items[i]);
- //name
- n:=p.name;
- SetLength(n,15);
- n:=n+'<'+IntToHex(Ord(p.name[15]),2)+'>';
- //type
- if((Ord(p.name_flags) and GROUP_NAME)<>0)then t:=' GROUP '
- else t:=' UNIQUE';
- //status
- if((Ord(p.name_flags) and REGISTERING)<>0)then s:=' REGISTERING'
- else if((Ord(p.name_flags) and REGISTERED)<>0)then s:=' REGISTERED'
- else if((Ord(p.name_flags) and DEREGISTERED)<>0)then s:=' DEREGISTERED'
- else if((Ord(p.name_flags) and DUPLICATE)<>0)then s:=' DUPLICATE'
- else if((Ord(p.name_flags) and DUPLICATE_DEREG)<>0)then s:=' DUPLICATE_DEREG';
- InfoList.Items.Add(n+t+s);
- end;
- end
- else InfoList.Items.Add('无法连接,目标的NetBEUI没有绑定到拨号适配器的TCP/IP上。');
- inf.Destroy;
- end;
- procedure TNetBiosInfoDlg.mClearClick(Sender: TObject);
- begin
- InfoList.Clear;
- end;
- procedure TNetBiosInfoDlg.mSaveClick(Sender: TObject);
- begin
- if(SaveDlg.Execute)then
- begin
- if(Sender is TMenuItem)then
- (
- (
- (Sender as TMenuItem).GetParentMenu as TPopupMenu
- ).PopupComponent as TListBox
- ).Items.SaveToFile(SaveDlg.FileName);
- end;
- end;
- end.