求XP下读网卡物理地址的问题。 要求能拔掉网线也读的出. 如题/ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 function GetPhysicalAddress: string;Var NCB : TNCB; ADAPTER : TADAPTERSTATUS; LANAENUM : TLANAENUM; intIdx : Integer; re : Char; buf : String;begin Try{ ZeroMemory(@NCB, SizeOf(NCB)); NCB.ncb_command := Chr(NCBENUM); re := NetBios(@NCB); // Reissue enum command NCB.ncb_buffer := @LANAENUM; NCB.ncb_length := SizeOf(LANAENUM); re := NetBios(@NCB); If Ord(re)<>0 Then exit; } { Copyright (C) Bowman } { [email protected] } // Reset adapter ZeroMemory(@NCB, SizeOf(NCB)); NCB.ncb_command := Chr(NCBRESET); NCB.ncb_lana_num := LANAENUM.lana[0];//important re := NetBios(@NCB); If Ord(re)<>0 Then begin Result := ''; exit; end; // Get adapter address ZeroMemory(@NCB, SizeOf(NCB)); NCB.ncb_command := Chr(NCBASTAT); NCB.ncb_lana_num := LANAENUM.lana[0];////bowman StrPCopy(NCB.ncb_callname, '*'); NCB.ncb_buffer := @ADAPTER.adapter_address[0]; NCB.ncb_length := SizeOf(ADAPTER); re := NetBios(@NCB); If Ord(re)<>0 Then exit; buf := ''; For intIdx := 0 To 5 Do buf := buf + InttoHex(Integer(ADAPTER.adapter_address[intIdx]),2)+'-'; Result := copy(buf,0,length(buf)-1); finally // freemem(@NCB,SizeOf(NCB)); end;end; mac地址吗?我想如果是的话http://www.8421.org/download.php?id=147 Wally_wu(韦利) ,你的根本读不出来,就算我不拔掉网线 sunny518(灵犀) ,你那个只是WIN2000,而我要的只XP。 nbtstat -A xx.xx.xx.xx > a.txt读取A.txt内容类似如下Node IpAddress: [10.103.111.134] Scope Id: [] NetBIOS Remote Machine Name Table Name Type Status --------------------------------------------- RUSTLE <00> UNIQUE Registered RUSTLE <20> UNIQUE Registered SPIC <00> GROUP Registered RUSTLE <03> UNIQUE Registered SPIC <1E> GROUP Registered INet~Services <1C> GROUP Registered IS~RUSTLE......<00> UNIQUE Registered MAC Address = 00-E0-4C-90-E3-B0 自己写程序的话:参考一下VC的做法,差不多的 http://www.pcvc.net/category/content.asp?sendid=229 调用命令行命令ipconfig/all Try this(Delphi6)....uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, nb30;implementation{$R *.dfm}function TForm1.NBGetAdapterAddress(a :Integer): string;var NC :TNCB; ADAPTE :TADAPTERSTATUS; LANAENU :TLANAENUM; intId :Integer; cR :Char; strTem :string;begin Result := ''; try ZeroMemory(@NC, SizeOf(NC)); NC.ncb_command := Chr(NCBENUM); cR := NetBios(@NC); //Reissue enum command NC.ncb_buffer := @LANAENU; NC.ncb_length := SizeOf(LANAENU); cR := NetBios(@NC); If Ord(cR) <> 0 then exit; ZeroMemory(@NC, SizeOf(NC)); NC.ncb_command := Chr(NCBRESET); NC.ncb_lana_num := LANAENU.lana[a]; cR := NetBios(@NC); if Ord(cR) <> 0 then exit; ZeroMemory(@NC, SizeOf(NC)); NC.ncb_command := Chr(NCBASTAT); NC.ncb_lana_num := LANAENU.lana[a]; StrPCopy(NC.ncb_callname, '*'); NC.ncb_buffer := @ADAPTE; NC.ncb_length := SizeOf(ADAPTE); cR := NetBios(@NC); strTem := ''; for intId := 0 To 5 do strTem := strTem+ InttoHex(Integer(ADAPTE.adapter_address[intId]), 2); Result := strTem; finally end;end;procedure TForm1.Button1Click(Sender: TObject);begin Edit1.Text := NBGetAdapterAddress(0); Beep;end; 谁说的﹐我还运行通过﹕unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, nb30;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}function GetPhysicalAddress: string;Var NCB : TNCB; ADAPTER : TADAPTERSTATUS; LANAENUM : TLANAENUM; intIdx : Integer; re : Char; buf : String;begin Try{ ZeroMemory(@NCB, SizeOf(NCB)); NCB.ncb_command := Chr(NCBENUM); re := NetBios(@NCB); // Reissue enum command NCB.ncb_buffer := @LANAENUM; NCB.ncb_length := SizeOf(LANAENUM); re := NetBios(@NCB); If Ord(re)<>0 Then exit; } { Copyright (C) Bowman } { [email protected] } // Reset adapter ZeroMemory(@NCB, SizeOf(NCB)); NCB.ncb_command := Chr(NCBRESET); NCB.ncb_lana_num := LANAENUM.lana[0];//important re := NetBios(@NCB); If Ord(re)<>0 Then begin Result := ''; exit; end; // Get adapter address ZeroMemory(@NCB, SizeOf(NCB)); NCB.ncb_command := Chr(NCBASTAT); NCB.ncb_lana_num := LANAENUM.lana[0];////bowman StrPCopy(NCB.ncb_callname, '*'); NCB.ncb_buffer := @ADAPTER.adapter_address[0]; NCB.ncb_length := SizeOf(ADAPTER); re := NetBios(@NCB); If Ord(re)<>0 Then exit; buf := ''; For intIdx := 0 To 5 Do buf := buf + InttoHex(Integer(ADAPTER.adapter_address[intIdx]),2)+'-'; Result := copy(buf,0,length(buf)-1); finally // freemem(@NCB,SizeOf(NCB)); end;end;procedure TForm1.Button1Click(Sender: TObject);begin showmessage(GetPhysicalAddress);end;end. Wally_wu(韦利) ,运行是通过,读出来是空的,什么也没有,我现在试的机器是win2000 server . swayi21(微斯人),你的读的不是真正的物理地址。在win 2000上根本不对。像你们前面的程序我以前就查过的。我有一个获取物理地址的程序,可以在win98,win 2000,下(是否拔掉网线)都能读出来,惟独win xp下拔掉网线读不出来,若是插上网线都能读的出来。 用DBGridEh1连接ADODataSet1,如何知道更新的是哪行数据? 谁帮忙写一个很简单的查询 网络正常,但SQL Server有时正常,有时连接不上 AdoQuery查询结果如何快速关闭? 一个基础问题! 关于Tchart 急待解决!!!!! 大家帮忙看看一段代码好吗? 如何取得系统的默认打印机 奇怪,Excel表会使Access数据出问题? 怎样给人加分呀,告知,就有分,UP///// DelPhi开发数据库怎么办?
Var
NCB : TNCB;
ADAPTER : TADAPTERSTATUS;
LANAENUM : TLANAENUM;
intIdx : Integer;
re : Char;
buf : String;
begin
Try
{ ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBENUM);
re := NetBios(@NCB); // Reissue enum command
NCB.ncb_buffer := @LANAENUM;
NCB.ncb_length := SizeOf(LANAENUM);
re := NetBios(@NCB);
If Ord(re)<>0 Then
exit;
}
{ Copyright (C) Bowman }
{ [email protected] }
// Reset adapter
ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBRESET);
NCB.ncb_lana_num := LANAENUM.lana[0];//important
re := NetBios(@NCB);
If Ord(re)<>0 Then
begin
Result := '';
exit;
end;
// Get adapter address
ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBASTAT);
NCB.ncb_lana_num := LANAENUM.lana[0];////bowman
StrPCopy(NCB.ncb_callname, '*');
NCB.ncb_buffer := @ADAPTER.adapter_address[0];
NCB.ncb_length := SizeOf(ADAPTER);
re := NetBios(@NCB);
If Ord(re)<>0 Then
exit; buf := '';
For intIdx := 0 To 5 Do
buf := buf + InttoHex(Integer(ADAPTER.adapter_address[intIdx]),2)+'-';
Result := copy(buf,0,length(buf)-1);
finally
// freemem(@NCB,SizeOf(NCB));
end;
end;
我想如果是的话
http://www.8421.org/download.php?id=147
Node IpAddress: [10.103.111.134] Scope Id: [] NetBIOS Remote Machine Name Table Name Type Status
---------------------------------------------
RUSTLE <00> UNIQUE Registered
RUSTLE <20> UNIQUE Registered
SPIC <00> GROUP Registered
RUSTLE <03> UNIQUE Registered
SPIC <1E> GROUP Registered
INet~Services <1C> GROUP Registered
IS~RUSTLE......<00> UNIQUE Registered MAC Address = 00-E0-4C-90-E3-B0
参考一下VC的做法,差不多的
http://www.pcvc.net/category/content.asp?sendid=229
ipconfig/all
(Delphi6)....
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, nb30;implementation{$R *.dfm}function TForm1.NBGetAdapterAddress(a :Integer): string;
var
NC :TNCB;
ADAPTE :TADAPTERSTATUS;
LANAENU :TLANAENUM;
intId :Integer;
cR :Char;
strTem :string;
begin
Result := '';
try
ZeroMemory(@NC, SizeOf(NC));
NC.ncb_command := Chr(NCBENUM);
cR := NetBios(@NC); //Reissue enum command
NC.ncb_buffer := @LANAENU;
NC.ncb_length := SizeOf(LANAENU);
cR := NetBios(@NC);
If Ord(cR) <> 0 then
exit; ZeroMemory(@NC, SizeOf(NC));
NC.ncb_command := Chr(NCBRESET);
NC.ncb_lana_num := LANAENU.lana[a];
cR := NetBios(@NC);
if Ord(cR) <> 0 then
exit; ZeroMemory(@NC, SizeOf(NC));
NC.ncb_command := Chr(NCBASTAT);
NC.ncb_lana_num := LANAENU.lana[a];
StrPCopy(NC.ncb_callname, '*');
NC.ncb_buffer := @ADAPTE;
NC.ncb_length := SizeOf(ADAPTE);
cR := NetBios(@NC);
strTem := '';
for intId := 0 To 5 do
strTem := strTem+ InttoHex(Integer(ADAPTE.adapter_address[intId]), 2);
Result := strTem;
finally
end;end;procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text := NBGetAdapterAddress(0);
Beep;
end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, nb30;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
function GetPhysicalAddress: string;
Var
NCB : TNCB;
ADAPTER : TADAPTERSTATUS;
LANAENUM : TLANAENUM;
intIdx : Integer;
re : Char;
buf : String;
begin
Try
{ ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBENUM);
re := NetBios(@NCB); // Reissue enum command
NCB.ncb_buffer := @LANAENUM;
NCB.ncb_length := SizeOf(LANAENUM);
re := NetBios(@NCB);
If Ord(re)<>0 Then
exit;
}
{ Copyright (C) Bowman }
{ [email protected] }
// Reset adapter
ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBRESET);
NCB.ncb_lana_num := LANAENUM.lana[0];//important
re := NetBios(@NCB);
If Ord(re)<>0 Then
begin
Result := '';
exit;
end;
// Get adapter address
ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBASTAT);
NCB.ncb_lana_num := LANAENUM.lana[0];////bowman
StrPCopy(NCB.ncb_callname, '*');
NCB.ncb_buffer := @ADAPTER.adapter_address[0];
NCB.ncb_length := SizeOf(ADAPTER);
re := NetBios(@NCB);
If Ord(re)<>0 Then
exit; buf := '';
For intIdx := 0 To 5 Do
buf := buf + InttoHex(Integer(ADAPTER.adapter_address[intIdx]),2)+'-';
Result := copy(buf,0,length(buf)-1);
finally
// freemem(@NCB,SizeOf(NCB));
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(GetPhysicalAddress);
end;end.