unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;const
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; type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
function RasEnumConnections( var lprasconn : RASCONN ;var lpcb: DWORD;var lpcConnections : DWORD) : DWORD; stdcall;
function RasEnumConnections:external'Rasapi32.dll';function RasGetProjectionInfo(hrasconn : HRasConn;rasprojection : DWORD;var lpprojection : TRASPPPIP;var lpcb : DWord) : DWORD;stdcall;
function RasGetProjectionInfo:external'Rasapi32.dll' ; procedure Button1Click(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
implementation{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);const
MaxConnections = 10;//假设最多有10个活动的拨号连接
var connections : array[0..MaxConnections-1] of RASCONN;
//拨号连接数组
longSize : dword;
intAvailabelConnections : dword;
//活动的拨号连接的实际数目
intIndex : integer;
strTemp : string;
dwResult : DWORD;
dwSize : DWORD;
RASpppIP : TRASPPPIP;
//活动的拨号连接的动态IP地址信息
begin
//libhandle:= LoadLibrary(';
connections[ 0 ].dwSize := sizeof(RASCONN);
longSize := MaxConnections * connections[ 0 ].dwSize;
//接收活动连接的缓冲区大小
intAvailabelConnections := 0;
//获取所有活动的拨号连接的信息(连接句柄和设置信息)
dwResult:= RasEnumConnections( connections[0],longSize,intAvailabelConnections );
if 0 <> dwResult then
memo1.lines.add( '错误:' + inttostr( dwResult ) )
else
begin
memo1.lines.add( '现有的活动连接有' +
IntToStr( intAvailabelConnections ) + '个');
//显示所有活动的拨号连接的信息(设置信息和动态IP地址)
for intIndex := 0 to intAvailabelConnections - 1 do
begin
//显示一个活动的拨号连接的设置信息
strTemp := '连接名称:'
+ StrPAS( connections[ intIndex ].szEntryName )
+ ',设备类型:'
+ StrPAS( connections[ intIndex ].szDeviceType )
+ ',设备名称:'
+ StrPAS( connections[ intIndex ].szDeviceName );
memo1.lines.add( strTemp );
//显示一个活动的拨号连接的动态IP地址
dwSize := SizeOf(RASpppIP);
RASpppIP.dwSize := dwSize;
dwResult := RASGetProjectionInfo( connections[ intIndex ].hRasConn,RASP_PppIp,RasPPPIP,dwSize);//获取动态IP地址
if 0 <> dwResult then
memo1.lines.add('错误:' + inttostr( dwResult ))
else
memo1.lines.add('动态地址:' + StrPas(RASpppIP.szIPAddress));
end;
end;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;const
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; type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
function RasEnumConnections( var lprasconn : RASCONN ;var lpcb: DWORD;var lpcConnections : DWORD) : DWORD; stdcall;
function RasEnumConnections:external'Rasapi32.dll';function RasGetProjectionInfo(hrasconn : HRasConn;rasprojection : DWORD;var lpprojection : TRASPPPIP;var lpcb : DWord) : DWORD;stdcall;
function RasGetProjectionInfo:external'Rasapi32.dll' ; procedure Button1Click(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
implementation{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);const
MaxConnections = 10;//假设最多有10个活动的拨号连接
var connections : array[0..MaxConnections-1] of RASCONN;
//拨号连接数组
longSize : dword;
intAvailabelConnections : dword;
//活动的拨号连接的实际数目
intIndex : integer;
strTemp : string;
dwResult : DWORD;
dwSize : DWORD;
RASpppIP : TRASPPPIP;
//活动的拨号连接的动态IP地址信息
begin
//libhandle:= LoadLibrary(';
connections[ 0 ].dwSize := sizeof(RASCONN);
longSize := MaxConnections * connections[ 0 ].dwSize;
//接收活动连接的缓冲区大小
intAvailabelConnections := 0;
//获取所有活动的拨号连接的信息(连接句柄和设置信息)
dwResult:= RasEnumConnections( connections[0],longSize,intAvailabelConnections );
if 0 <> dwResult then
memo1.lines.add( '错误:' + inttostr( dwResult ) )
else
begin
memo1.lines.add( '现有的活动连接有' +
IntToStr( intAvailabelConnections ) + '个');
//显示所有活动的拨号连接的信息(设置信息和动态IP地址)
for intIndex := 0 to intAvailabelConnections - 1 do
begin
//显示一个活动的拨号连接的设置信息
strTemp := '连接名称:'
+ StrPAS( connections[ intIndex ].szEntryName )
+ ',设备类型:'
+ StrPAS( connections[ intIndex ].szDeviceType )
+ ',设备名称:'
+ StrPAS( connections[ intIndex ].szDeviceName );
memo1.lines.add( strTemp );
//显示一个活动的拨号连接的动态IP地址
dwSize := SizeOf(RASpppIP);
RASpppIP.dwSize := dwSize;
dwResult := RASGetProjectionInfo( connections[ intIndex ].hRasConn,RASP_PppIp,RasPPPIP,dwSize);//获取动态IP地址
if 0 <> dwResult then
memo1.lines.add('错误:' + inttostr( dwResult ))
else
memo1.lines.add('动态地址:' + StrPas(RASpppIP.szIPAddress));
end;
end;
end;end.
解决方案 »
- 用winexec和shellexecute都无法打开这个exe文件,为什么
- 纯粹放分,祝贺自己刚生存255555个小时
- 十六进制转换十进制的函数
- ZIPTV控件解压.TAR.Z文件后成为一.tar.txt文件,请问该文件如解再解开?
- 自定以大小打印问题,(98,win2000)都可以用
- StringGrid.options.goEditing := true 这样写对吗?
- 高分求助!
- 如何使用treeview控件的一些属性?
- 我找不到带有 ww的控件,help me!
- 为什么我的分总是0,不加了????? 斑蛛在哪?!
- 如何进行两个文件大小的比较?
- Delphi编的Web Service系统中,调用CGI的服务器端程序为什么打开数据库会出错?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;const
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; type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
function RasEnumConnections( var lprasconn : RASCONN ;var lpcb: DWORD;var lpcConnections : DWORD) : DWORD; stdcall;
function RasGetProjectionInfo(hrasconn : HRasConn;rasprojection : DWORD;var lpprojection : TRASPPPIP;var lpcb : DWord) : DWORD;stdcall;
procedure Button1Click(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
implementation{$R *.dfm}function Tform1.RasGetProjectionInfo(hrasconn : HRasConn;rasprojection : DWORD;var lpprojection : TRASPPPIP;var lpcb : DWord) : DWORD;external'Rasapi32.dll' name 'funname2';function Tform1.RasEnumConnections( var lprasconn : RASCONN ;var lpcb: DWORD;var lpcConnections : DWORD) : DWORD;external 'Rasapi32.dll' name 'funname2';procedure TForm1.Button1Click(Sender: TObject);const
MaxConnections = 10;//¼ÙÉè×î¶àÓÐ10¸ö»î¶¯µÄ²¦ºÅÁ¬½Ó
var connections : array[0..MaxConnections-1] of RASCONN;
//²¦ºÅÁ¬½ÓÊý×é
longSize : dword;
intAvailabelConnections : dword;
//»î¶¯µÄ²¦ºÅÁ¬½ÓµÄʵ¼ÊÊýÄ¿
intIndex : integer;
strTemp : string;
dwResult : DWORD;
dwSize : DWORD;
RASpppIP : TRASPPPIP;
//»î¶¯µÄ²¦ºÅÁ¬½ÓµÄ¶¯Ì¬IPµØÖ·ÐÅÏ¢
begin
//libhandle:= LoadLibrary(';
connections[ 0 ].dwSize := sizeof(RASCONN);
longSize := MaxConnections * connections[ 0 ].dwSize;
//½ÓÊջÁ¬½ÓµÄ»º³åÇø´óС
intAvailabelConnections := 0;
//»ñÈ¡ËùÓлµÄ²¦ºÅÁ¬½ÓµÄÐÅÏ¢£¨Á¬½Ó¾ä±úºÍÉèÖÃÐÅÏ¢£©
dwResult:= RasEnumConnections( connections[0],longSize,intAvailabelConnections );
if 0 <> dwResult then
memo1.lines.add( '´íÎó:' + inttostr( dwResult ) )
else
begin
memo1.lines.add( 'ÏÖÓеĻÁ¬½ÓÓÐ' +
IntToStr( intAvailabelConnections ) + '¸ö');
//ÏÔʾËùÓлµÄ²¦ºÅÁ¬½ÓµÄÐÅÏ¢£¨ÉèÖÃÐÅÏ¢ºÍ¶¯Ì¬IPµØÖ·£©
for intIndex := 0 to intAvailabelConnections - 1 do
begin
//ÏÔʾһ¸ö»î¶¯µÄ²¦ºÅÁ¬½ÓµÄÉèÖÃÐÅÏ¢
strTemp := 'Á¬½ÓÃû³Æ£º'
+ StrPAS( connections[ intIndex ].szEntryName )
+ '£¬É豸ÀàÐÍ£º'
+ StrPAS( connections[ intIndex ].szDeviceType )
+ '£¬É豸Ãû³Æ£º'
+ StrPAS( connections[ intIndex ].szDeviceName );
memo1.lines.add( strTemp );
//ÏÔʾһ¸ö»î¶¯µÄ²¦ºÅÁ¬½ÓµÄ¶¯Ì¬IPµØÖ·
dwSize := SizeOf(RASpppIP);
RASpppIP.dwSize := dwSize;
dwResult := RASGetProjectionInfo( connections[ intIndex ].hRasConn,RASP_PppIp,RasPPPIP,dwSize);//»ñÈ¡¶¯Ì¬IPµØÖ·
if 0 <> dwResult then
memo1.lines.add('´íÎó:' + inttostr( dwResult ))
else
memo1.lines.add('¶¯Ì¬µØÖ·:' + StrPas(RASpppIP.szIPAddress));
end;
end;
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;const
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; type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
function RasEnumConnections( var lprasconn : RASCONN ;var lpcb: DWORD;var lpcConnections : DWORD) : DWORD; stdcall;function RasGetProjectionInfo(hrasconn : HRasConn;rasprojection : DWORD;var lpprojection : TRASPPPIP;var lpcb : DWord) : DWORD;stdcall;
procedure Button1Click(Sender: TObject); private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
implementation{$R *.dfm}function Tform1.RasGetProjectionInfo(hrasconn : HRasConn;rasprojection : DWORD;var lpprojection : TRASPPPIP;var lpcb : DWord) : DWORD;external'Rasapi32.dll' name 'funname2';function Tform1.RasEnumConnections( var lprasconn : RASCONN ;var lpcb: DWORD;var lpcConnections : DWORD) : DWORD;external 'Rasapi32.dll' name 'funname2';procedure TForm1.Button1Click(Sender: TObject);const
MaxConnections = 10;//假设最多有10个活动的拨号连接
var connections : array[0..MaxConnections-1] of RASCONN;
//拨号连接数组
longSize : dword;
intAvailabelConnections : dword;
//活动的拨号连接的实际数目
intIndex : integer;
strTemp : string;
dwResult : DWORD;
dwSize : DWORD;
RASpppIP : TRASPPPIP;
//活动的拨号连接的动态IP地址信息
begin
//libhandle:= LoadLibrary(';
connections[ 0 ].dwSize := sizeof(RASCONN);
longSize := MaxConnections * connections[ 0 ].dwSize;
//接收活动连接的缓冲区大小
intAvailabelConnections := 0;
//获取所有活动的拨号连接的信息(连接句柄和设置信息)
dwResult:= RasEnumConnections( connections[0],longSize,intAvailabelConnections );
if 0 <> dwResult then
memo1.lines.add( '错误:' + inttostr( dwResult ) )
else
begin
memo1.lines.add( '现有的活动连接有' +
IntToStr( intAvailabelConnections ) + '个');
//显示所有活动的拨号连接的信息(设置信息和动态IP地址)
for intIndex := 0 to intAvailabelConnections - 1 do
begin
//显示一个活动的拨号连接的设置信息
strTemp := '连接名称:'
+ StrPAS( connections[ intIndex ].szEntryName )
+ ',设备类型:'
+ StrPAS( connections[ intIndex ].szDeviceType )
+ ',设备名称:'
+ StrPAS( connections[ intIndex ].szDeviceName );
memo1.lines.add( strTemp );
//显示一个活动的拨号连接的动态IP地址
dwSize := SizeOf(RASpppIP);
RASpppIP.dwSize := dwSize;
dwResult := RASGetProjectionInfo( connections[ intIndex ].hRasConn,RASP_PppIp,RasPPPIP,dwSize);//获取动态IP地址
if 0 <> dwResult then
memo1.lines.add('错误:' + inttostr( dwResult ))
else
memo1.lines.add('动态地址:' + StrPas(RASpppIP.szIPAddress));
end;
end;
end;end.