api是不晓得,但可以这样去得到<br><br> function getipaftvpn():string;<br> var Buf: array[0..MAX_PATH] of Char;<br> Path,Cmd,S:string;<br> F:TextFile;<br> i:integer;<br> tmp:Tstringlist;<br> a,b:integer;<br> tmp2:string;<br> begin<br><br> GetWindowsDirectory(Buf,MAX_PATH);<br> if string(Buf)[Length(string(Buf))]<>'/' then<br> Path:=string(Buf)+'/'<br> else<br> Path:= string(Buf);<br><br> if FileExists(path+'VPNIP.txt') then DeleteFile(path+'VPNIP.txt');<br> Cmd:='command.com /c ipconfig /all > '+path+'VPNIP.txt';<br> //Winexec(pchar(Cmd),sw_hide);<br> WinExecAndWait32(pchar(cmd),sw_hide);<br> while not FileExists(path+'VPNIP.txt') do<br> begin<br> Sleep(50);<br> end;<br> if FileExists(path+'VPNIP.txt') then Sleep(100);<br> try<br> tmp:=Tstringlist.Create;<br> tmp.LoadFromFile(Path+'Vpnip.txt');<br> for a:=0 to tmp.Count -1 do<br> begin<br> if pos('网络加速连接',tmp.Strings[a])<>0 then<br> begin<br> for b:=a to tmp.Count -1 do<br> begin<br> tmp2:=tmp.Strings;<br> if tmp2=' IP Address. . . . . . . . . . . . : ' then<br> begin<br> Continue;<br> end;<br> if pos('IP Address. . . . . . . . . . . . :',tmp2)<>0 then<br> begin<br> tmp2:=Trim(tmp2);<br> i:=pos(':',tmp2);<br> Delete(tmp2,1,i);<br> Result:=Trim(tmp2);<br> tmp.Free;<br> exit;<br> end;<br> end;<br> end;<br> end;<br><br> except<br> Result:='';<br> tmp.Free;<br> exit;<br> end;<br><br><br>end;