Ver Mensaje Individual
  #12  
Antiguo 07-07-2012
barakuda barakuda is offline
Miembro
 
Registrado: mar 2010
Posts: 79
Reputación: 15
barakuda Va por buen camino
Gracias a seoane ya pude hacer funcionar el codigo, hay partes que no controlo asi que me toca "romperlas" y estudiarlas, por cierto muestro el código en su totalidad ya funcionando:

Código Delphi [-]unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, winsock, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; Edit1: TEdit; Label2: TLabel; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; type PULONG = ^ULONG; var Form1: TForm1; implementation {$R *.dfm} function SendARP(DestIP,SrcIP: in_addr; pMacAddr,PhyAddrLen: PULONG): DWORD; stdcall; external 'iphlpapi.dll' name 'SendARP'; function ObtenerMAC(IP: Ansistring): Ansistring; var i: Integer; dwRetVal: DWORD; DestIp, SrcIp: in_addr; MacAddr: array[0..1] of ULONG; PhysAddrLen: ULONG; PhysAddr: PByte; begin DestIp.S_addr:= 0; SrcIp.S_addr:= 0; PhysAddrLen:= 6; DestIp.S_addr:= inet_addr(PAnsiChar(AnsiString(IP))); dwRetVal:= SendARP(DestIp, SrcIp, @MacAddr, @PhysAddrLen); Result:= EmptyStr; if dwRetVal = NO_ERROR then begin PhysAddr:= PByte(@MacAddr); for i := 1 to Sizeof(MacAddr)-2 do begin if Result= EmptyStr then Result:= IntToHex(PhysAddr^,2) else Result:= Result + '-' + IntToHex(PhysAddr^,2); inc(PhysAddr); end; end; end; procedure TForm1.Button1Click(Sender: TObject); begin label1.Caption:=ObtenerMAC(edit1.Text); end; end.


Como veis le añadir un campo edit + 2 label y un botón,

gracias a todos.
Responder Con Cita