如何在启动机器时自动运行adsl拨号(1)
2008-04-09 04:27:16来源:互联网 阅读 ()
我们通常希望有一台机器能经常挂在网上,现在有了adsl包月服务,这已经不是问题。但是最近adsl总是会断线,当我回家想从公司的机器上拷贝一些文件的时候,有时会发现已经连接不上了。所以我做个程序所要实现的功能有这么两个,一是用程序来实现adsl拨号,二是要定时检测网络状态,三是要在启动机器时运行(既注册为服务)
我们先看一下如何做一个拨号程序
首先建一个ras拨号的单元文件(这是网上搜集的)
unit Ras;
interface
uses
Windows, SysUtils;
{$DEFINE WINVER400}
const
RasUnitVersion = 110;
CopyRight : String = '''' RasUnit (c) 97-98 F. Piette V1.10 '''';
rasapi32 = ''''rasapi32.dll'''';
UNLEN = 256; // Maximum user name length
PWLEN = 256; // Maximum password length
CNLEN = 15; // Computer name length
DNLEN = CNLEN; // Maximum domain name length
RAS_MaxDeviceType = 16;
RAS_MaxPhoneNumber = 128;
RAS_MaxIpAddress = 15;
RAS_MaxIpxAddress = 21;
{$IFDEF WINVER400}
RAS_MaxEntryName = 256;
RAS_MaxDeviceName = 128;
RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;
{$ELSE}
RAS_MaxEntryName = 20;
RAS_MaxDeviceName = 32;
RAS_MaxCallbackNumber = 48;
{$ENDIF}
RAS_MaxAreaCode = 10;
RAS_MaxPadType = 32;
RAS_MaxX25Address = 200;
RAS_MaxFacilities = 200;
RAS_MaxUserData = 200;
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;
{$IFDEF WINVER400}
RASCS_StartAuthentication = 19;
RASCS_CallbackComplete = 20;
RASCS_LogonNetwork = 21;
{$ENDIF}
RASCS_SubEntryConnected = 22;
RASCS_SubEntryDisconnected= 23;
RASCS_PAUSED = $1000;
RASCS_Interactive = RASCS_PAUSED;
RASCS_RetryAuthentication = (RASCS_PAUSED 1);
RASCS_CallbackSetByCaller = (RASCS_PAUSED 2);
RASCS_PasswordExpired = (RASCS_PAUSED 3);
RASCS_DONE = $2000;
RASCS_Connected = RASCS_DONE;
RASCS_Disconnected = (RASCS_DONE 1);
// If using RasDial message notifications, get the notification message code
// by passing this string to the RegisterWindowMessageA() API.
// WM_RASDIALEVENT is used only if a unique message cannot be registered.
RASDIALEVENT = ''''RasDialEvent'''';
WM_RASDIALEVENT = $CCCD;
// TRASPROJECTION
RASP_Amb = $10000;
RASP_PppNbf = $0803F;
RASP_PppIpx = $0802B;
RASP_PppIp = $08021;
RASP_Slip = $20000;
type
THRASCONN = THandle;
PHRASCONN = ^THRASCONN;
TRASCONNSTATE = DWORD;
PDWORD = ^DWORD;
PBOOL = ^BOOL;
TRASDIALPARAMS = packed record
dwSize : DWORD;
szEntryName : array [0..RAS_MaxEntryName] of Char;
szPhoneNumber : array [0..RAS_MaxPhoneNumber] of Char;
szCallbackNumber : array [0..RAS_MaxCallbackNumber] of Char;
szUserName : array [0..UNLEN] of Char;
szPassword : array [0..PWLEN] of Char;
szDomain : array [0..DNLEN] of Char;
{$IFDEF WINVER401}
dwSubEntry : DWORD;
dwCallbackId : DWORD;
{$ENDIF}
szPadding : array [0..2] of Char;
end;
PRASDIALPARAMS = ^TRASDIALPARAMS;
TRASDIALEXTENSIONS = packed record
dwSize : DWORD;
dwfOptions : DWORD;
hwndParent : HWND;
reserved : DWORD;
end;
PRASDIALEXTENSIONS = ^TRASDIALEXTENSIONS;
TRASCONNSTATUS = packed record
dwSize : DWORD;
RasConnState : TRASCONNSTATE;
dwError : DWORD;
szDeviceType : array [0..RAS_MaxDeviceType] of char;
szDeviceName : array [0..RAS_MaxDeviceName] of char;
szPadding : array [0..1] of Char;
end;
PRASCONNSTATUS = ^TRASCONNSTATUS;
TRASCONN = packed record
dwSize : DWORD;
hRasConn : THRASCONN;
szEntryName : array [0..RAS_MaxEntryName] of char;
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash