我把最楼上的改了一下便于您拷贝.
procedure TForm1.Button1Click(Sender: TObject);
const
MaxConnections = 10;//¼ÙÉè×î¶àÓÐ10¸ö»î¶¯µÄ²¦ºÅÁ¬½Ó
RAS_MaxDeviceType = 16; //É豸ÀàÐÍÃû³Æ³¤¶È
RAS_MaxEntryName = 256; //Á¬½ÓÃû³Æ×î´ó³¤¶È
RAS_MaxDeviceName = 128; //É豸Ãû³Æ×î´ó³¤¶È
RAS_MaxIpAddress = 15; //IPµØÖ·µÄ×î´ó³¤¶È
RASP_PppIp = $8021; //²¦ºÅÁ¬½ÓµÄЭÒéÀàÐÍ£¬
//¸ÃÊýÖµ±íʾPPPÁ¬½Ó
type
HRASCONN = DWORD; //²¦ºÅÁ¬½Ó¾ä±úµÄÀàÐÍ
RASCONN = record //»î¶¯µÄ²¦ºÅÁ¬½ÓµÄ¾ä±úºÍÉèÖÃÐÅÏ¢
dwSize : DWORD; //¸Ã½á¹¹ËùÕ¼ÄÚ´æµÄ´óС(Bytes),Ò»°ãÉèÖÃΪSizeOf(RASCONN)
hrasconn : HRASCONN; //»î¶¯Á¬½ÓµÄ¾ä±ú
szEntryName : array[0..RAS_MaxEntryName] of char;//»î¶¯Á¬½ÓµÄÃû³Æ
szDeviceType :array[0..RAS_MaxDeviceType] of char;//»î¶¯Á¬½ÓµÄËùÓõÄÉ豸ÀàÐÍ
szDeviceName :array[0..RAS_MaxDeviceName] of char;//»î¶¯Á¬½ÓµÄËùÓõÄÉ豸Ãû³Æ
end;
TRASPPPIP = record //»î¶¯µÄ²¦ºÅÁ¬½ÓµÄ¶¯Ì¬IPµØÖ·ÐÅÏ¢
dwSize : DWORD; //¸Ã½á¹¹ËùÕ¼ÄÚ´æµÄ´óС(Bytes),Ò»°ãÉèÖÃΪSizeOf(TRASPPPIP)
dwError : DWORD; //´íÎóÀàÐͱêʶ·û
szIpAddress : array[ 0..RAS_MaxIpAddress ] of char;//»î¶¯µÄ²¦ºÅÁ¬½ÓµÄIPµØÖ·
end;
var
RasEnumConnections: function(
var lprasconn : RASCONN ;//½ÓÊջÁ¬½ÓµÄ»º³åÇøµÄÖ¸Õë
var lpcb: DWORD;//»º³åÇø´óС
var lpcConnections : DWORD//ʵ¼ÊµÄ»î¶¯Á¬½ÓÊý
)
WORD; stdcall;
RasGetProjectionInfo: function (
hrasconn : HRasConn;//Ö¸¶¨»î¶¯Á¬½ÓµÄ¾ä±ú
rasprojection : DWORD;//RASÁ¬½ÓÀàÐÍ
var lpprojection : TRASPPPIP;//½ÓÊÕ¶¯Ì¬IPÐÅÏ¢µÄ»º³åÇø
var lpcb : DWord//½ÓÊÕ»º³åÇøµÄ´óС
): DWORD;stdcall;
connections : array[0..MaxConnections-1] of RASCONN; //²¦ºÅÁ¬½ÓÊý×é
longSize : dword;
intAvailabelConnections:dword; //»î¶¯µÄ²¦ºÅÁ¬½ÓµÄʵ¼ÊÊýÄ¿
intIndex : integer;
strTemp : string;
dwResult : DWORD;
RASpppIP : TRASPPPIP; //»î¶¯µÄ²¦ºÅÁ¬½ÓµÄ¶¯Ì¬IPµØÖ·ÐÅÏ¢
hand1,hand2:thandle;
begin
hand1:=loadlibrary('Rasapi32.dll');
if hand1=0 then exit;
try
@RasEnumConnections:=getprocaddress(hand1,'RasEnumConnectionsA');
if @RasEnumConnections=nil then exit;
hand2:=loadlibrary('Rasapi32.dll');
if hand2=0 then exit;
try
@RasGetProjectionInfo:=getprocaddress(hand2,'RasGetProjectionInfoA');
if @RasGetProjectionInfo=nil then exit;
connections[0].dwSize := sizeof(RASCONN);
longSize := MaxConnections*connections[0].dwSize; //½ÓÊջÁ¬½ÓµÄ»º³åÇø´óС
dwResult := RasEnumConnections(connections[0],longSize,intAvailabelConnections);
if 0 <> dwResult then memo1.lines.add( '&acute;í&Icirc;ó:' + inttostr( dwResult ) )
else
begin
memo1.lines.add('&Iuml;&Ouml;&Oacute;&ETH;&micro;&Auml;&raquo;&icirc;&para;&macr;&Aacute;&not;&frac12;&Oacute;&Oacute;&ETH;'+IntToStr(intAvailabelConnections)+'&cedil;&ouml;');
//&Iuml;&Ocirc;&Ecirc;&frac34;&Euml;ù&Oacute;&ETH;&raquo;&icirc;&para;&macr;&micro;&Auml;&sup2;&brvbar;&ordm;&Aring;&Aacute;&not;&frac12;&Oacute;&micro;&Auml;&ETH;&Aring;&Iuml;&cent;&pound;¨&Eacute;è&Ouml;&Atilde;&ETH;&Aring;&Iuml;&cent;&ordm;&Iacute;&para;&macr;&Igrave;&not;IP&micro;&Oslash;&Ouml;·&pound;&copy;
for intIndex := 0 to intAvailabelConnections - 1 do
begin//&Iuml;&Ocirc;&Ecirc;&frac34;&Ograve;&raquo;&cedil;&ouml;&raquo;&icirc;&para;&macr;&micro;&Auml;&sup2;&brvbar;&ordm;&Aring;&Aacute;&not;&frac12;&Oacute;&micro;&Auml;&Eacute;è&Ouml;&Atilde;&ETH;&Aring;&Iuml;&cent;
strTemp :=
'&Aacute;&not;&frac12;&Oacute;&Atilde;&ucirc;&sup3;&AElig;:' +StrPAS(connections[intIndex].szEntryName )
+'&pound;&not;&Eacute;è±&cedil;&Agrave;à&ETH;&Iacute;&pound;&ordm;' +StrPAS(connections[intIndex].szDeviceType )
+'&pound;&not;&Eacute;è±&cedil;&Atilde;&ucirc;&sup3;&AElig;&pound;&ordm;' +StrPAS(connections[intIndex].szDeviceName );
memo1.lines.add( strTemp ); //&Iuml;&Ocirc;&Ecirc;&frac34;&Ograve;&raquo;&cedil;&ouml;&raquo;&icirc;&para;&macr;&micro;&Auml;&sup2;&brvbar;&ordm;&Aring;&Aacute;&not;&frac12;&Oacute;&micro;&Auml;&para;&macr;&Igrave;&not;IP&micro;&Oslash;&Ouml;·
RASpppIP.dwSize := SizeOf(RASpppIP);
dwResult := RASGetProjectionInfo(connections[intIndex].hRasConn,
RASP_PppIp,RasPPPIP,RASpppIP.dwSize);//&raquo;&ntilde;&Egrave;&iexcl;&para;&macr;&Igrave;&not;IP&micro;&Oslash;&Ouml;·
if 0 <> dwResult then
memo1.lines.add('&acute;í&Icirc;ó:' + inttostr( dwResult ))
else
memo1.lines.add('&para;&macr;&Igrave;&not;&micro;&Oslash;&Ouml;·:'+StrPas(RASpppIP.szIPAddress));
end;
end;//end of dwresult
finally
freelibrary(hand2);
end;
finally
freelibrary(hand1);
end;
end;
2000下可以运行.