Home | 10% - Off! | New | VCL | DB-Aware | Tools | DB Tools | Apps | Samples | .NET | .NET DB-Aware | .NET Tools | .NET Samples | Kylix | Docs | Bold | Discussion | Sites | Tips | DPFL | Authors | Uploads | RSS | Store | Advertisement | About
DPFL

Information
Introduction
Rules
Advertisement
Categories
Graphics
System
Forms
Windows
Databases
Math routines
Internet
Units/Libraries
RGB2HLS
DzURL
Delphi Procedures and Function Library > Categories > Internet

Click and process to the routine implementation...
LongIP() shortIP() GetURL() dwtoa() atodw()

Author Target Keywords Description
Stian Gronland (joepezt@c2i.net http://joepezt.moonlit.net) D2?/D3?/D4/D5 Internet, IP, algorithm converting Converting from ShortIP and LongIP
function LongIP(IP : string) : string;
var
  IPaddr   : array[1..4] of integer;
  temp     : string;
  res      : Longword;
  i        : integer;

begin
  temp := ip;
  temp := temp + '.';
  for i := 1 to 4 do
  begin
    ipaddr[i] := strtoint(copy(temp,1,pos('.',temp) - 1));
    delete(temp,1,pos('.',temp));
  end;
  // Check the IP
  for i := 1 to 4 do
  begin
    try
       inttostr(ipaddr[i]);
    except
       result := 'Invalid IP address.';
       exit;
    end;
  end;

  res := (ipaddr[1] * $FFFFFF) + ipaddr[1] +
           (ipaddr[2] * $FFFF)   + ipaddr[2] +
           (ipaddr[3] * $FF)     + ipaddr[3] +
           (ipaddr[4]);
           result := inttostr(res);
end;
Author Target Keywords Description
Stian Gronland (joepezt@c2i.net http://joepezt.moonlit.net) D2?/D3?/D4/D5 Internet, IP, algorithm converting Converting from ShortIP and LongIP
function shortIP(const S: string): string;
var
  IP        : integer;
  A, B, C, D: byte;
begin
  IP:=StrToInt(S);
  A:=(IP and $FF000000) shr 24;
  B:=(IP and $FF0000) shr 16;
  C:=(IP and $FF00) shr 8;
  D:=IP and $FF;
  result:=Format('%d.%d.%d.%d', [A, B, C, D]);
end;
Author Target Keywords Description
Bernt Levinsson http://w1.321.telia.com/~u32102551/ D2/D3/D4/D5 System, Internet, URL The anti OLE way of get url from an URL shortcut;-)
function GetURL(URL: TFilename): string;
var
  ini: TIniFile;
begin
  ini := TIniFile.Create(URL);
  try
    result := ini.ReadString('InternetShortcut', 'URL', '');
  except;
    result := '';
    ini.Free;
    ini := nil;
  end;
  if Assigned(ini) then
    ini.Free;
end;
Author Target Keywords Description
Icehawk D1/D2/D3/D4/D5 IP, DWORD, Endian, Swap, DCC Obtaining IP as/from DWORD
{dword to atom routine}
function dwtoa(dw: DWORD): string;
var
  inaddr: TInAddr;
begin
  asm
    mov eax,dw; {move the int to the accumulation register}
    BSWAP eax;  {swap the high and low order word         }
    mov dw,eax; {move result back to dw variable          }
  end;
  inaddr.S_addr:=dw;
  result:=inet_ntoa(inaddr);
end;

{atom to dword routine}
function atodw(s: string): DWORD;
var
  dw: DWORD;
begin
  dw:=inet_addr(PChar(s));
  asm
    mov eax,dw; {move the int to the accumulation register}
    BSWAP eax;  {swap the high and low order word         }
    mov dw,eax; {move result back to dw variable          }
  end;
  result:=dw;
end;


Advertising on Torry's Delphi Pages

Quick Search
Exact phrase
Title
Description

Useful Books

Advertising on Torry's Delphi Pages

Visit Our Delphi Site.

Up | Home | 10% - Off! | New | VCL | DB-Aware | Tools | DB Tools | Apps | Samples | .NET | .NET DB-Aware | .NET Tools | .NET Samples | Kylix | Docs | Bold | Discussion | Sites | Tips | DPFL | Authors | Uploads | RSS | Store | Advertisement | About
Copyright © Torry's Delphi Pages Torry's Delphi Pages Maintained by A. Berman. Notes? Comments? Feel free to send... Copyright © 1996-2002
All trademarks are the sole property of their respective owners
Do not click! Special anti-spammer page!