分类: Delphi
2014-02-19 13:22:06
问题描述:
此函数在win7 64位下面无法正常运行,原因未知?
使用头文件 NB30
function GetMAC(sIP: String): String;
var
i: Integer;
s: String;
NCB: TNCB;
Adapter: TAdapterStatus;
LanaEnum: TLanaEnum;
cRC: Char;
begin
Result := '';
try
ZeroMemory(@NCB, SizeOf(NCB));
//MsgDlg('=============',mtError);
NCB.ncb_command := Chr(NCBENUM);
NetBios(@NCB);
NCB.ncb_buffer := @LanaEnum;
NCB.ncb_length := SizeOf(LanaEnum);
cRC := NetBios(@NCB);
//MsgDlg('==============!',mtError);
if Ord(cRC) <> 0 then
begin
Exit;
end;
//MsgDlg('==============!',mtError);
ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBRESET);
NCB.ncb_lana_num := LanaEnum.lana[0];
cRC := NetBios(@NCB);
if Ord(cRC) <> 0 then
begin
exit;
end;
// MsgDlg('==============!',mtError);
ZeroMemory(@NCB, SizeOf(NCB));
NCB.ncb_command := Chr(NCBASTAT);
NCB.ncb_lana_num := LanaEnum.lana[0];
// MsgDlg('========+++++++++======!',mtError);
StrCopy(NCB.ncb_callname, pchar(sIP));
// MsgDlg('=========99999999999=====!',mtError);
NCB.ncb_buffer := @Adapter;
NCB.ncb_length := SizeOf(Adapter);
// MsgDlg('==========-------====!',mtError);
NetBios(@NCB);
// MsgDlg('======888888888========!',mtError);
s := '';
for i := 0 to 5 do
s := s + InttoHex(Integer(Adapter.adapter_address[i]), 2);
Result := s;
finally
end;
end;