可以根据拨号名取拨号的IP地址
function GetDialAddress(dialName: string): string;
const
MaxConnections = 10; //假设最多有10个活动的拨号连接
var
connections : array[0..MaxConnections - 1] of TRasConn;
//拨号连接数组
longSize : Longint;
intAvailabelConnections: Longint;
//活动的拨号连接的实际数目
intIndex : integer;
strTemp : string;
dwResult : DWORD;
dwSize : Longint;
RASpppIP : TRASPPPIP;
//活动的拨号连接的动态IP地址信息
begin
connections[0].dwSize := sizeof(TRasConn);
longSize := MaxConnections * connections[0].dwSize;
//接收活动连接的缓冲区大小
intAvailabelConnections := 0;
//获取所有活动的拨号连接的信息(连接句柄和设置信息)
dwResult := RasEnumConnections(@connections[0],
longSize, intAvailabelConnections);
if 0 <> dwResult then
begin
result := '';
exit;
end;
for intIndex := 0 to intAvailabelConnections - 1 do
if StrPAS(connections[intIndex].szEntryName) = DialName then
begin
dwSize := SizeOf(RASpppIP);
RASpppIP.dwSize := dwSize;
dwResult := RASGetProjectionInfo
(connections[intIndex].hRasConn,
RASP_PppIp, @RasPPPIP, dwSize); //获取动态IP地址
if 0 = dwResult then
begin
strTemp := StrPas(RASpppIP.szIpAddress);
result := strTemp;
end
else result := '';
exit;
end;
end;