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

Код:
uses
  WinSock, WinInet,
...
var
  URL: String;
  lpUrlComponents: TURLComponents;
  lpszHostName: array [0..$1f] of Char;
  dwURL: Integer;
begin
  URL:='192.168.1.101:27015';
  ZeroMemory(@lpUrlComponents, SizeOf(TURLComponents));
  lpUrlComponents.dwStructSize:=SizeOf(TURLComponents);
  lpUrlComponents.lpszHostName:=@lpszHostName[0];
  lpUrlComponents.dwHostNameLength:=Length(lpszHostName);
  if InternetCrackUrl(PChar('http://'+URL), 7+Length(URL), ICU_DECODE, lpUrlComponents) then
  begin
    dwURL:=inet_addr(@lpszHostName[0]);
    if dwURL=INADDR_NONE then RaiseLastOSError;
    // out
    Memo1.Lines.Add(IntToStr((dwURL shr 0) and $ff));
    Memo1.Lines.Add(IntToStr((dwURL shr 8) and $ff));
    Memo1.Lines.Add(IntToStr((dwURL shr 16) and $ff));
    Memo1.Lines.Add(IntToStr((dwURL shr 24) and $ff));
    Memo1.Lines.Add(':');
    Memo1.Lines.Add(IntToStr(lpUrlComponents.nPort));
    // out
  end else RaiseLastOSError;
end;
__________________
Пишу программы за еду.
__________________
Ответить с цитированием