unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Winsock, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function SendARP(Destip,scrip:DWORD;pmacaddr:PDWORD;VAR phyAddrlen:DWORD):DWORD; stdcall ;external 'iphlpapi.dll' ;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetmacFromIP(IP: String): String;
type
Tinfo = array[0..7] of byte;
var
dwTargetIP: dword;
dwmacAddress: array[0..1] of DWORD;
dwmacLen: DWORD;
dwResult: DWORD;
X: Tinfo;
stemp:string;
iloop:integer;
begin
dwTargetIP := Inet_Addr(pchar(ip));
dwmacLen := 6;
dwResult := SendARP(dwtargetip,0,@dwmacaddress[0], dwmaclen);
if dwResult= NO_ERROR then
begin
x:= tinfo(dwmacAddress);
for iloop:= 0 to 5 do
begin
stemp:= stemp+inttohex(x[iloop],2);
end;
Result:= stemp;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// Edit1 에 도메인 내의 IP를 입력하고 버튼을 클릭하면 mac 주소를 구해옵니다
Edit2.Text := GetmacFromIP(Edit1.Text);
end;
end.
'델파이' 카테고리의 다른 글
[델파이] IP Helper API 를 이용한 "ipconfig /all" 구현 (0) | 2019.10.04 |
---|---|
[델파이] Ethernet 랜카드의 mac adress 구하기 (0) | 2019.10.02 |
[델파이] 델파이에서 사용되는 정수형 변수들 (0) | 2019.10.02 |
[델파이] 프로세스 우선순위 올리기 (0) | 2019.10.02 |
[델파이] 델파이 실행파일 Virus.Win32.Induc.a 감염 해결방법 (0) | 2019.10.01 |