![]() |
Eine Netzmaske von CIDR in Dezimal umwandeln
Hallo zusammen,
hier ein wenig Code der bei meinem letzten Projekt abgefallen ist. Vielleicht kanns ja wer brauchen. Es geht darum aus der ![]() erzeugen (zB 255.255.255.0).
Delphi-Quellcode:
Aufruf (Beispiel):function num_to_ip(IpAsLong : LongWord) : String; var a,b,c,d : integer; begin a := (IpAsLong shr 24) and $FF; b := (IpAsLong shr 16) and $FF; c := (IpAsLong shr 8) and $FF; d := IpAsLong and $FF; Result := inttostr(a) + '.' + inttostr(b) + '.' + inttostr(c) + '.' + inttostr(d); end; function cidr_to_netmask(cidr : integer) : string; var tmp : LongWorD; begin tmp := ( $FFFFFFFF shl (32 - cidr) ); Result := num_to_ip(tmp); end;
Delphi-Quellcode:
[edit=Daniel G] Mfg, Daniel G[/edit]
procedure TForm1.Button1Click(Sender: TObject);
begin listbox1.Items.add(cidr_to_netmask(24)); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:41 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz