Ver Mensaje Individual
  #4  
Antiguo 02-07-2006
CCCP CCCP is offline
Miembro
 
Registrado: dic 2004
Ubicación: Barcelona
Posts: 38
Reputación: 0
CCCP Va por buen camino
Saber el api de un pc

Código Delphi [-]
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    Function GetIp(var Host:String):String;
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
Uses WinSock;
{$R *.dfm}
Function TForm1.GetIp(var Host:String):String;
type
  TAPInAddr = Array[0..100] of PInAddr;
  PAPInAddr = ^TAPInAddr;
var
  WSAData: TWSAData;
  HostEntPtr: PHostEnt;
  pptr: PAPInAddr;
  i,iPos: Integer;
begin
  Result:='';
  If Host <> '' then Begin
     WSAStartUp( $101, WSAData );
     HostEntPtr := GetHostByName( PChar( Host ) );
     if HostEntPtr = NIL then GetIp:='';
     If Assigned(HostEntPtr) then Begin
     pptr := PAPInAddr( HostEntPtr^.h_addr_list );
     i := 0;
     while pptr^[i] <> NIL do begin
      Result:=inet_ntoa( pptr^[i]^ );
      Inc( i );
     end;
     end;
     WSACleanUp();
  end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var Host:String;
begin
 Host:='HOST';
 Showmessage(GetIp(Host))
end;
end.
Responder Con Cita