Good morning,
I am using the method below to return the IP of the computer, but if I have an active VPN on the computer, it is getting the IP of the VPN first and not the machine. I would like to know if it would be possible to control which IP it returns me or another way so I can get the real IP of the computer (from a network card) and not from the VPN and also if it would be possible to get only IPV4 and not IPV6.
Thank you and I await.
Follow the code below:
function GetLocalIP: String;
var
ipwsa:TWSAData;
p:PHostEnt;
s:array[0..128] of char;
c : PAnsiChar;
begin
c := '';
try
wsastartup(257,ipwsa);
GetHostName(@s, 128);
p := GetHostByName(@s);
c := iNet_ntoa(PInAddr(p^.h_addr_list^)^);
except
on E: Exception do
begin
TVSMLogUtils.GetInstance.LogE(E.Message);
end;
end;
Result := String(c);
end;