Показать сообщение отдельно
  #2  
Старый 19.08.2014, 19:18
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

Код:
program Project1;

{$APPTYPE CONSOLE}

type
  TWSAData = record
    wVersion: Word;
    wHighVersion: Word;
    szDescription: array[0..256] of Char;
    szSystemStatus: array[0..128] of Char;
    iMaxSockets: Word;
    iMaxUdpDg: Word;
    lpVendorInfo: PChar;
  end;

  PHostEnt = ^THostEnt;
  THostEnt = record
    h_name: PChar;
    h_aliases: ^PChar;
    h_addrtype: Smallint;
    h_length: Smallint;
    case Byte of
      0: (h_addr_list: ^PChar);
      1: (h_addr: ^PChar)
  end;

  SunB = packed record
    s_b1, s_b2, s_b3, s_b4: Char;
  end;

  SunW = packed record
    s_w1, s_w2: Word;
  end;
  
  PInAddr = ^TInAddr;
  TInAddr = record
    case integer of
      0: (S_un_b: SunB);
      1: (S_un_w: SunW);
      2: (S_addr: Longint);
  end;

function WSAStartup(wVersionRequired: word; var WSData: TWSAData): Integer; stdcall; external 'wsock32.dll';
function WSACleanup: Integer; stdcall; external 'wsock32.dll';
function gethostbyname(name: PChar): PHostEnt; stdcall; external 'wsock32.dll';
function inet_ntoa(inaddr: TInAddr): PChar; stdcall; external 'wsock32.dll';

var
  WSAData: TWSAData;
  HostEnt: PHostEnt;

begin
  WSAStartup(514, WSAData);
  HostEnt:=gethostbyname('www.delphisources.ru');
  Writeln(inet_ntoa(PInAddr(HostEnt^.h_addr_list^)^));
  WSACleanup;
  Readln;
end.

вообще ни одного модуля
__________________
Пишу программы за еду.
__________________
Ответить с цитированием