文章目录
【Delphi控件ADSL拨号和断开】
提示:这里可以添加技术概要
使用的拨号控件是开源的DialUp.pas,只要建了一个包,加入这个文件后,就可以编译建立TDialUp控件。顺便多说一句,安装好后,该控件放在“Internet”页上。
使用举例:
获取宽带链接列表
Combobox1.Items:=DialUp1.PossibleConnections;
拨号例子
DialUp1.Username:=Edit_Name.Text;
DialUp1.Password:=Edit_Pwd.Text;
DialUp1.ConnectTo:=ComboBox1.Text;
DialUp1.GoOnline
断开连接
DialUp1.GoOffline;
核心源码
unit DialUp;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
const
DNLEN = 15;
UNLEN = 256;
PWLEN = 256;
RAS_MaxEntryName = 256;
RAS_MaxDeviceType = 16;
RAS_MaxDeviceName = 128;
RAS_MaxPhoneNumber = 128;
RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;
RASCS_PAUSED = $1000;
RASCS_DONE = $2000;
RASCS_OpenPort = 0;
RASCS_PortOpened = 1;
RASCS_ConnectDevice = 2;
RASCS_DeviceConnected = 3;
RASCS_AllDevicesConnected = 4;
RASCS_Authenticate = 5;
RASCS_AuthNotify = 6;
RASCS_AuthRetry = 7;
RASCS_AuthCallback = 8;
RASCS_AuthChangePassword = 9;
RASCS_AuthProject = 10;
RASCS_AuthLinkSpeed = 11;
RASCS_AuthAck = 12;
RASCS_ReAuthenticate = 13;
RASCS_Authenticated = 14;
RASCS_PrepareForCallback = 15;
RASCS_WaitForModemReset = 16;
RASCS_WaitForCallback = 17;
RASCS_Projected = 18;
RASCS_StartAuthentication = 19;
RASCS_CallbackComplete = 20;
RASCS_LogonNetwork = 21;
RASCS_Interactive = RASCS_PAUSED;
RASCS_RetryAuthentication = RASCS_PAUSED + 1;
RASCS_CallbackSetByCaller = RASCS_PAUSED + 2;
RASCS_PasswordExpired = RASCS_PAUSED + 3;
RASCS_Connected = RASCS_DONE;
RASCS_Disconnected = RASCS_DONE + 1;
type
THRasConn = Longint;
LPRasConnA = ^TRasConnA;
TRasConnA = record
dwSize : Longint;
hrasconn : THRasConn;
szEntryName : array[0…RAS_MaxEntryName] of AnsiChar;
szDeviceType : array[0…RAS_MaxDeviceType] of AnsiChar;
szDeviceName : array[0…RAS_MaxDeviceName] of AnsiChar;
end;
LPRasConn = ^TRasConn;
TRasConn = TRasConnA;
LPRasConnState = ^TRasConnState;
TRasConnState = Integer;
LPRasConnStatusA = ^TRasConnStatusA;
TRasConnStatusA = record
dwSize : Longint;
rasconnstate : TRasConnState;
dwError : LongInt;
szDeviceType : array[0…RAS_MaxDeviceType] of AnsiChar;
szDeviceName : array[0…RAS_MaxDeviceName] of AnsiChar;
end;
LPRasConnStatus = ^TRasConnStatus;
TRasConnStatus = TRasConnStatusA;
LPRasEntryNameA = ^TRasEntryNameA;
TRasEntryNameA = record
dwSize : Longint;
szEntryName : array[0…RAS_MaxEntryName] of AnsiChar;
end;
LPRasEntryN