![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
какпо имени компа или айпи узнать мас адресс??
скажите плиз??? Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,NB30, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetAdapterInfo(Lana: Char): String;
var
Adapter: TAdapterStatus;
NCB: TNCB;
begin
FillChar(NCB, SizeOf(NCB), 0);
NCB.ncb_command := Char(NCBRESET);
NCB.ncb_lana_num := Lana;
if Netbios(@NCB) <> Char(NRC_GOODRET) then
begin
Result := 'mac not found';
Exit;
end;
FillChar(NCB, SizeOf(NCB), 0);
NCB.ncb_command := Char(NCBASTAT);
NCB.ncb_lana_num := Lana;
NCB.ncb_callname := '*';
FillChar(Adapter, SizeOf(Adapter), 0);
NCB.ncb_buffer := @Adapter;
NCB.ncb_length := SizeOf(Adapter);
if Netbios(@NCB) <> Char(NRC_GOODRET) then
begin
Result := 'mac not found';
Exit;
end;
Result :=
IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[5]), 2);
end;
function GetMACAddress: string;
var
AdapterList: TLanaEnum;
NCB: TNCB;
begin
FillChar(NCB, SizeOf(NCB), 0);
NCB.ncb_command := Char(NCBENUM);
NCB.ncb_buffer := @AdapterList;
NCB.ncb_length := SizeOf(AdapterList);
Netbios(@NCB);
if Byte(AdapterList.length) > 0 then
Result := GetAdapterInfo(AdapterList.lana[0])
else
Result := 'mac not found';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=GetMACAddress;
end;
end.это показывает мас на локальной машине тоесть мой а как чтоб например в Edit вводил йпи иои имя и он мне выводил мас адресс той ашины?? это реально или неи? |
|
#2
|
|||
|
|||
|
Ну в винде можно сделать так:
Цитата:
Цитата:
Соответственно, то же самое можно реализовать на Delphi. |
|
#3
|
||||
|
||||
|
|
|
#4
|
|||
|
|||
|
Люди хочу определить мак адрес компов в сети делаю так
Код:
function SendARP(DestIP: DWORD; SrcIP: DWORD; pMacAddr: PDWORD; var
PhyAddrLen: DWORD): DWORD; stdcall; external 'IPHlpAPI.DLL';
function GetRemoteMACAddress(DestIP: string): string;
type
TInfo = array[0..7] of BYTE;
var
dwTargetIP: DWORD;
dwMacAddress: array[0..1] of DWORD;
dwMacLen: DWORD;
dwResult: DWORD;
X: TInfo;
begin
dwTargetIP := Inet_Addr(PChar(DestIP));
dwMacLen := 6;
dwResult := SendARP(dwTargetIP, 0, @dwMacAddress[0], dwMacLen);
if dwResult = NO_ERROR then
begin
X := TInfo(dwMacAddress);
Result := Format('%x.%x.%x.%x.%x.%x',
[X[0], X[1], X[2], X[3], X[4], X[5]]);
end;
end;
потом эту функцию применяю к кнопке и в эдит выводу мак адресс так:
Edit3.Text:=GetRemoteMACAddress(Edit4.Text); и вывожу мас в Edit43 но показывает его не полностью а так:0.13.D3.97.9B.E1 как можно заметить в начале нехватате 1 значение в чом проблема??? |