如何取得IP地址的前3串数字?
比如 192.168.1.2 如何获得 192.168.1 这3串数字,方法越简单越好。
[解决办法]
- Delphi(Pascal) code
function Get3(AIP: string): string;var i: integer;begin result := ''; for i := Length(AIP) downto 1 do if AIP(i) = '.' then begin result := copy(AIP,1,i-1); Break; end;end;
[解决办法]
IP := ChangeFileExt('192.168.1.2' , '');
^-^