兄弟们,谁有RSA的delphi源码,来一份,谢谢! (100分)

  • 主题发起人 主题发起人 mmww
  • 开始时间 开始时间
M

mmww

Unregistered / Unconfirmed
GUEST, unregistred user!
兄弟们,谁有RSA的delphi源码,来一份,谢谢!
 
有的话给我也来一份吧!谢过先!
dirk_c@sina.com
 
我有,要的留下Email!特别是楼主,我没有看见您的Email。
 
需要的赶紧帖,我明天一并发送。
 
roc@t198.com
谢了!
 

是什么来的?来一份看看。[:D]
[:D]shadow@acec.com.cn[:D]

 
我有兴趣,可不可以也给我来一份?marklai2001@sina.com[:)]
 
也给我一份吧谢谢

 
也来一份:)
sspwlixia@21cn.com
 
daoguowang@sohu.com

谢谢
 
to zqw0117:
谢谢!我的Emai是:gold_net@163.com
 
unit Dialup;

interface

uses
SysUtils, Windows, Dialogs, Classes, ExtCtrls, Forms, Messages;

const
DNLEN = 15; // Maximum domain name length
UNLEN = 256; // Maximum user name length
PWLEN = 256; // Maximum password length
NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)

RAS_MaxDeviceType = 16;
RAS_MaxPhoneNumber = 128;
RAS_MaxIpAddress = 15;
RAS_MaxIpxAddress = 21;
RAS_MaxEntryName = 256;
RAS_MaxDeviceName = 128;
RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;

type
LPHRasConn = ^THRasConn;
THRasConn = Longint;

LPRasConnW = ^TRasConnW;
TRasConnW = record
dwSize : Longint;
hrasconn : THRasConn;
szEntryName : Array[0..RAS_MaxEntryName] of WideChar;
szDeviceType : Array[0..RAS_MaxDeviceType] of WideChar;
szDeviceName : Array[0..RAS_MaxDeviceName] of WideChar;
end;

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;

const
RASCS_PAUSED = $1000;
RASCS_DONE = $2000;

type
LPRasConnState = ^TRasConnState;
TRasConnState = Integer;

const
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
LPRasConnStatusW = ^TRasConnStatusW;
TRasConnStatusW = record
dwSize : Longint;
rasconnstate : TRasConnState;
dwError : LongInt;
szDeviceType : Array[0..RAS_MaxDeviceType] of WideChar;
szDeviceName : Array[0..RAS_MaxDeviceName] of WideChar;
end;

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;

LPRasDialParamsW = ^TRasDialParamsW;
TRasDialParamsW = record
dwSize : LongInt;
szEntryName : Array[0..RAS_MaxEntryName] of WideChar;
szPhoneNumber : Array[0..RAS_MaxPhoneNumber] of WideChar;
szCallbackNumber : Array[0..RAS_MaxCallbackNumber] of WideChar;
szUserName : Array[0..UNLEN] of WideChar;
szPassword : Array[0..PWLEN] of WideChar;
szDomain : Array[0..DNLEN] of WideChar;
end;

LPRasDialParamsA = ^TRasDialParamsA;
TRasDialParamsA = record
dwSize : LongInt;
szEntryName : Array[0..RAS_MaxEntryName] of AnsiChar;
szPhoneNumber : Array[0..RAS_MaxPhoneNumber] of AnsiChar;
szCallbackNumber : Array[0..RAS_MaxCallbackNumber] of AnsiChar;
szUserName : Array[0..UNLEN] of AnsiChar;
szPassword : Array[0..PWLEN] of AnsiChar;
szDomain : Array[0..DNLEN] of AnsiChar;
end;

LPRasDialParams = ^TRasDialParams;
TRasDialParams = TRasDialParamsA;

LPRasDialExtensions = ^TRasDialExtensions;
TRasDialExtensions = record
dwSize : LongInt;
dwfOptions : LongInt;
hwndParent : HWND;
reserved : LongInt;
end;

const
{* 'dwfOptions' bit flags.*}
RDEOPT_UsePrefixSuffix = $00000001;
RDEOPT_PausedStates = $00000002;
RDEOPT_IgnoreModemSpeaker = $00000004;
RDEOPT_SetModemSpeaker = $00000008;
RDEOPT_IgnoreSoftwareCompression = $00000010;
RDEOPT_SetSoftwareCompression = $00000020;


type

LPRasEntryNameW = ^TRasEntryNameW;
TRasEntryNameW = record
dwSize : Longint;
szEntryName : Array[0..RAS_MaxEntryName] of WideChar;
end;

LPRasEntryNameA = ^TRasEntryNameA;
TRasEntryNameA = record
dwSize : Longint;
szEntryName : Array[0..RAS_MaxEntryName] of AnsiChar;
end;

LPRasEntryName = ^TRasEntryName;
TRasEntryName = TRasEntryNameA;

LPRasProjection = ^TRasProjection;
TRasProjection = Integer;

const
RASP_Amb = $10000;
RASP_PppNbf = $803F;
RASP_PppIpx = $802B;
RASP_PppIp = $8021;

type
LPRasAmbW = ^TRasAmbW;
TRasAmbW = record
dwSize : Longint;
dwError : Longint;
szNetBiosError : Array[0..NETBIOS_NAME_LEN] of WideChar;
bLana : Byte;
end;

LPRasAmbA = ^TRasAmbA;
TRasAmbA = record
dwSize : Longint;
dwError : Longint;
szNetBiosError : Array[0..NETBIOS_NAME_LEN] of AnsiChar;
bLana : Byte;
end;

LPRasAmb = ^TRasAmb;
TRasAmb = TRasAmbA;

LPRasPppNbfW = ^TRasPppNbfW;
TRasPppNbfW = record
dwSize : Longint;
dwError : Longint;
dwNetBiosError : Longint;
szNetBiosError : Array[0..NETBIOS_NAME_LEN] of WideChar;
szWorkstationName : Array[0..NETBIOS_NAME_LEN] of WideChar;
bLana : Byte;
end;

LPRasPppNbfA = ^TRasPppNbfA;
TRasPppNbfA = record
dwSize : Longint;
dwError : Longint;
dwNetBiosError : Longint;
szNetBiosError : Array[0..NETBIOS_NAME_LEN] of AnsiChar;
szWorkstationName : Array[0..NETBIOS_NAME_LEN] of AnsiChar;
bLana : Byte;
end;

LpRaspppNbf = ^TRasPppNbf;
TRasPppNbf = TRasPppNbfA;

LPRasPppIpxW = ^TRasPppIpxW;
TRasPppIpxW = record
dwSize : Longint;
dwError : Longint;
szIpxAddress : Array[0..RAS_MaxIpxAddress] of WideChar;
end;

LPRasPppIpxA = ^TRasPppIpxA;
TRasPppIpxA = record
dwSize : Longint;
dwError : Longint;
szIpxAddress : Array[0..RAS_MaxIpxAddress] of AnsiChar;
end;

LPRasPppIpx = ^TRasPppIpx;
TRasPppIpx = TRasPppIpxA;

LPRasPppIpW = ^TRasPppIpW;
TRasPppIpW = record
dwSize : Longint;
dwError : Longint;
szIpAddress : Array[0..RAS_MaxIpAddress] of WideChar;

{$IFNDEF WINNT35COMPATIBLE}
szServerIpAddress: Array[0..RAS_MaxIpAddress] of WideChar;
{$ENDIF}
end;

LPRasPppIpA = ^TRasPppIpA;
TRasPppIpA = record
dwSize : Longint;
dwError : Longint;
szIpAddress : Array[0..RAS_MaxIpAddress] of AnsiChar;

{$IFNDEF WINNT35COMPATIBLE} {* See RASPPPIPW comment. *}
szServerIpAddress: Array[0..RAS_MaxIpAddress] of AnsiChar;
{$ENDIF}
end;

LPRasPppIp = ^TRasPppIp;
TRasPppIp = TRasPppIpA;


const
RASDIALEVENT = 'RasDialEvent';
WM_RASDIALEVENT = $CCCD;

function RasDialA(lpRasDialExt: LPRasDialExtensions; lpszPhoneBook: PAnsiChar;
var params: TRasDialParamsA; dwNotifierType: Longint;
lpNotifier: Pointer; var rasconn: THRasConn): Longint; stdcall;
function RasDialW(lpRasDialExt: LPRasDialExtensions; lpszPhoneBook: PWideChar;
var params: TRasDialParamsW; dwNotifierType: Longint;
lpNotifier: Pointer; var rasconn: THRasConn): Longint; stdcall;
function RasDial(lpRasDialExt: LPRasDialExtensions; lpszPhoneBook: PAnsiChar;
var params: TRasDialParams; dwNotifierType: Longint;
lpNotifier: Pointer; var rasconn: THRasConn): Longint; stdcall;
function RasEnumConnectionsA(RasConnArray: LPRasConnA; var lpcb: Longint;
var lpcConnections: Longint): Longint; stdcall;
function RasEnumConnectionsW(RasConnArray: LPRasConnW; var lpcb: Longint;
var lpcConnections: Longint): Longint; stdcall;
function RasEnumConnections(RasConnArray: LPRasConn; var lpcb: Longint;
var lpcConnections: Longint): Longint; stdcall;
function RasEnumEntriesA(Reserved: PAnsiChar; lpszPhoneBook: PAnsiChar;
entrynamesArray: LPRasEntryNameA; var lpcb: Longint;
var lpcEntries: Longint): Longint; stdcall;
function RasEnumEntriesW(reserved: PWideChar; lpszPhoneBook: PWideChar;
entrynamesArray: LPRasEntryNameW; var lpcb: Longint;
var lpcEntries: Longint): Longint; stdcall;
function RasEnumEntries(reserved: PAnsiChar; lpszPhoneBook: PAnsiChar;
entrynamesArray: LPRasEntryName; var lpcb: Longint;
var lpcEntries: Longint): Longint; stdcall;
function RasGetConnectStatusA(hConn: THRasConn; var lpStatus: TRasConnStatusA): Longint; stdcall;
function RasGetConnectStatusW(hConn: THRasConn;var lpStatus: TRasConnStatusW): Longint; stdcall;
function RasGetConnectStatus(hConn: THRasConn;var lpStatus: TRasConnStatus): Longint; stdcall;
function RasGetErrorStringA(errorValue: Integer;erroString: PAnsiChar;cBufSize: Longint): Longint; stdcall;
function RasGetErrorStringW(errorValue: Integer;erroString: PWideChar;cBufSize: Longint): Longint; stdcall;
function RasGetErrorString(errorValue: Integer;erroString: PAnsiChar;cBufSize: Longint): Longint; stdcall;
function RasHangUpA(hConn: THRasConn): Longint; stdcall;
function RasHangUpW(hConn: THRasConn): Longint; stdcall;
function RasHangUp(hConn: THRasConn): Longint; stdcall;
function RasGetProjectionInfoA(hConn: THRasConn; rasproj: TRasProjection;
lpProjection: Pointer; var lpcb: Longint): Longint; stdcall;
function RasGetProjectionInfoW(hConn: THRasConn; rasproj: TRasProjection;
lpProjection: Pointer; var lpcb: Longint): Longint; stdcall;
function RasGetProjectionInfo(hConn: THRasConn; rasproj: TRasProjection;
lpProjection: Pointer; var lpcb: Longint): Longint; stdcall;
function RasCreatePhonebookEntryA(hwndParentWindow: HWND;lpszPhoneBook: PAnsiChar): Longint; stdcall;
function RasCreatePhonebookEntryW(hwndParentWindow: HWND;lpszPhoneBook: PWideChar): Longint; stdcall;
function RasCreatePhonebookEntry(hwndParentWindow: HWND;lpszPhoneBook: PAnsiChar): Longint; stdcall;
function RasEditPhonebookEntryA(hwndParentWindow: HWND; lpszPhoneBook: PAnsiChar;
lpszEntryName: PAnsiChar): Longint; stdcall;
function RasEditPhonebookEntryW(hwndParentWindow: HWND; lpszPhoneBook: PWideChar;
lpszEntryName: PWideChar): Longint; stdcall;
function RasEditPhonebookEntry(hwndParentWindow: HWND; lpszPhoneBook: PAnsiChar;
lpszEntryName: PAnsiChar): Longint; stdcall;
function RasSetEntryDialParamsA(lpszPhoneBook: PAnsiChar; var lpDialParams: TRasDialParamsA;
fRemovePassword: LongBool): Longint; stdcall;
function RasSetEntryDialParamsW(lpszPhoneBook: PWideChar; var lpDialParams: TRasDialParamsW;
fRemovePassword: LongBool): Longint; stdcall;
function RasSetEntryDialParams(lpszPhoneBook: PAnsiChar; var lpDialParams: TRasDialParams;
fRemovePassword: LongBool): Longint; stdcall;
function RasGetEntryDialParamsA(lpszPhoneBook: PAnsiChar; var lpDialParams: TRasDialParamsA;
var lpfPassword: LongBool): Longint; stdcall;
function RasGetEntryDialParamsW(lpszPhoneBook: PWideChar; var lpDialParams: TRasDialParamsW;
var lpfPassword: LongBool): Longint; stdcall;
function RasGetEntryDialParams(lpszPhoneBook: PAnsiChar; var lpDialParams: TRasDialParams;
var lpfPassword: LongBool): Longint; stdcall;

const
RASBASE = 600;
SUCCESS = 0;

PENDING = (RASBASE+0);
ERROR_INVALID_PORT_HANDLE = (RASBASE+1);
ERROR_PORT_ALREADY_OPEN = (RASBASE+2);
ERROR_BUFFER_TOO_SMALL = (RASBASE+3);
ERROR_WRONG_INFO_SPECIFIED = (RASBASE+4);
ERROR_CANNOT_SET_PORT_INFO = (RASBASE+5);
ERROR_PORT_NOT_CONNECTED = (RASBASE+6);
ERROR_EVENT_INVALID = (RASBASE+7);
ERROR_DEVICE_DOES_NOT_EXIST = (RASBASE+8);
ERROR_DEVICETYPE_DOES_NOT_EXIST = (RASBASE+9);
ERROR_BUFFER_INVALID = (RASBASE+10);
ERROR_ROUTE_NOT_AVAILABLE = (RASBASE+11);
ERROR_ROUTE_NOT_ALLOCATED = (RASBASE+12);
ERROR_INVALID_COMPRESSION_SPECIFIED = (RASBASE+13);
ERROR_OUT_OF_BUFFERS = (RASBASE+14);
ERROR_PORT_NOT_FOUND = (RASBASE+15);
ERROR_ASYNC_REQUEST_PENDING = (RASBASE+16);
ERROR_ALREADY_DISCONNECTING = (RASBASE+17);
ERROR_PORT_NOT_OPEN = (RASBASE+18);
ERROR_PORT_DISCONNECTED = (RASBASE+19);
ERROR_NO_ENDPOINTS = (RASBASE+20);
ERROR_CANNOT_OPEN_PHONEBOOK = (RASBASE+21);
ERROR_CANNOT_LOAD_PHONEBOOK = (RASBASE+22);
ERROR_CANNOT_FIND_PHONEBOOK_ENTRY = (RASBASE+23);
ERROR_CANNOT_WRITE_PHONEBOOK = (RASBASE+24);
ERROR_CORRUPT_PHONEBOOK = (RASBASE+25);
ERROR_CANNOT_LOAD_STRING = (RASBASE+26);
ERROR_KEY_NOT_FOUND = (RASBASE+27);
ERROR_DISCONNECTION = (RASBASE+28);
ERROR_REMOTE_DISCONNECTION = (RASBASE+29);
ERROR_HARDWARE_FAILURE = (RASBASE+30);
ERROR_USER_DISCONNECTION = (RASBASE+31);
ERROR_INVALID_SIZE = (RASBASE+32);
ERROR_PORT_NOT_AVAILABLE = (RASBASE+33);
ERROR_CANNOT_PROJECT_CLIENT = (RASBASE+34);
ERROR_UNKNOWN = (RASBASE+35);
ERROR_WRONG_DEVICE_ATTACHED = (RASBASE+36);
ERROR_BAD_STRING = (RASBASE+37);
ERROR_REQUEST_TIMEOUT = (RASBASE+38);
ERROR_CANNOT_GET_LANA = (RASBASE+39);
ERROR_NETBIOS_ERROR = (RASBASE+40);
ERROR_SERVER_OUT_OF_RESOURCES = (RASBASE+41);
ERROR_NAME_EXISTS_ON_NET = (RASBASE+42);
ERROR_SERVER_GENERAL_NET_FAILURE = (RASBASE+43);
WARNING_MSG_ALIAS_NOT_ADDED = (RASBASE+44);
ERROR_AUTH_INTERNAL = (RASBASE+45);
ERROR_RESTRICTED_LOGON_HOURS = (RASBASE+46);
ERROR_ACCT_DISABLED = (RASBASE+47);
ERROR_PASSWD_EXPIRED = (RASBASE+48);
ERROR_NO_DIALIN_PERMISSION = (RASBASE+49);
ERROR_SERVER_NOT_RESPONDING = (RASBASE+50);
ERROR_FROM_DEVICE = (RASBASE+51);
ERROR_UNRECOGNIZED_RESPONSE = (RASBASE+52);
ERROR_MACRO_NOT_FOUND = (RASBASE+53);
ERROR_MACRO_NOT_DEFINED = (RASBASE+54);
ERROR_MESSAGE_MACRO_NOT_FOUND = (RASBASE+55);
ERROR_DEFAULTOFF_MACRO_NOT_FOUND = (RASBASE+56);
ERROR_FILE_COULD_NOT_BE_OPENED = (RASBASE+57);
ERROR_DEVICENAME_TOO_LONG = (RASBASE+58);
ERROR_DEVICENAME_NOT_FOUND = (RASBASE+59);
ERROR_NO_RESPONSES = (RASBASE+60);
ERROR_NO_COMMAND_FOUND = (RASBASE+61);
ERROR_WRONG_KEY_SPECIFIED = (RASBASE+62);
ERROR_UNKNOWN_DEVICE_TYPE = (RASBASE+63);
ERROR_ALLOCATING_MEMORY = (RASBASE+64);
ERROR_PORT_NOT_CONFIGURED = (RASBASE+65);
ERROR_DEVICE_NOT_READY = (RASBASE+66);
ERROR_READING_INI_FILE = (RASBASE+67);
ERROR_NO_CONNECTION = (RASBASE+68);
ERROR_BAD_USAGE_IN_INI_FILE = (RASBASE+69);
ERROR_READING_SECTIONNAME = (RASBASE+70);
ERROR_READING_DEVICETYPE = (RASBASE+71);
ERROR_READING_DEVICENAME = (RASBASE+72);
ERROR_READING_USAGE = (RASBASE+73);
ERROR_READING_MAXCONNECTBPS = (RASBASE+74);
ERROR_READING_MAXCARRIERBPS = (RASBASE+75);
ERROR_LINE_BUSY = (RASBASE+76);
ERROR_VOICE_ANSWER = (RASBASE+77);
ERROR_NO_ANSWER = (RASBASE+78);
ERROR_NO_CARRIER = (RASBASE+79);
ERROR_NO_DIALTONE = (RASBASE+80);
ERROR_IN_COMMAND = (RASBASE+81);
ERROR_WRITING_SECTIONNAME = (RASBASE+82);
ERROR_WRITING_DEVICETYPE = (RASBASE+83);
ERROR_WRITING_DEVICENAME = (RASBASE+84);
ERROR_WRITING_MAXCONNECTBPS = (RASBASE+85);
ERROR_WRITING_MAXCARRIERBPS = (RASBASE+86);
ERROR_WRITING_USAGE = (RASBASE+87);
ERROR_WRITING_DEFAULTOFF = (RASBASE+88);
ERROR_READING_DEFAULTOFF = (RASBASE+89);
ERROR_EMPTY_INI_FILE = (RASBASE+90);
ERROR_AUTHENTICATION_FAILURE = (RASBASE+91);
ERROR_PORT_OR_DEVICE = (RASBASE+92);
ERROR_NOT_BINARY_MACRO = (RASBASE+93);
ERROR_DCB_NOT_FOUND = (RASBASE+94);
ERROR_STATE_MACHINES_NOT_STARTED = (RASBASE+95);
ERROR_STATE_MACHINES_ALREADY_STARTED = (RASBASE+96);
ERROR_PARTIAL_RESPONSE_LOOPING = (RASBASE+97);
ERROR_UNKNOWN_RESPONSE_KEY = (RASBASE+98);
ERROR_RECV_BUF_FULL = (RASBASE+99);
ERROR_CMD_TOO_LONG = (RASBASE+100);
ERROR_UNSUPPORTED_BPS = (RASBASE+101);
ERROR_UNEXPECTED_RESPONSE = (RASBASE+102);
ERROR_INTERACTIVE_MODE = (RASBASE+103);
ERROR_BAD_CALLBACK_NUMBER = (RASBASE+104);
ERROR_INVALID_AUTH_STATE = (RASBASE+105);
ERROR_WRITING_INITBPS = (RASBASE+106);
ERROR_X25_DIAGNOSTIC = (RASBASE+107);
ERROR_ACCT_EXPIRED = (RASBASE+108);
ERROR_CHANGING_PASSWORD = (RASBASE+109);
ERROR_OVERRUN = (RASBASE+110);
ERROR_RASMAN_CANNOT_INITIALIZE = (RASBASE+111);
ERROR_BIPLEX_PORT_NOT_AVAILABLE = (RASBASE+112);
ERROR_NO_ACTIVE_ISDN_LINES = (RASBASE+113);
ERROR_NO_ISDN_CHANNELS_AVAILABLE = (RASBASE+114);
ERROR_TOO_MANY_LINE_ERRORS = (RASBASE+115);
ERROR_IP_CONFIGURATION = (RASBASE+116);
ERROR_NO_IP_ADDRESSES = (RASBASE+117);
ERROR_PPP_TIMEOUT = (RASBASE+118);
ERROR_PPP_REMOTE_TERMINATED = (RASBASE+119);
ERROR_PPP_NO_PROTOCOLS_CONFIGURED = (RASBASE+120);
ERROR_PPP_NO_RESPONSE = (RASBASE+121);
ERROR_PPP_INVALID_PACKET = (RASBASE+122);
ERROR_PHONE_NUMBER_TOO_LONG = (RASBASE+123);
ERROR_IPXCP_NO_DIALOUT_CONFIGURED = (RASBASE+124);
ERROR_IPXCP_NO_DIALIN_CONFIGURED = (RASBASE+125);
ERROR_IPXCP_DIALOUT_ALREADY_ACTIVE = (RASBASE+126);
ERROR_ACCESSING_TCPCFGDLL = (RASBASE+127);
ERROR_NO_IP_RAS_ADAPTER = (RASBASE+128);
ERROR_SLIP_REQUIRES_IP = (RASBASE+129);
ERROR_PROJECTION_NOT_COMPLETE = (RASBASE+130);
ERROR_PROTOCOL_NOT_CONFIGURED = (RASBASE+131);
ERROR_PPP_NOT_CONVERGING = (RASBASE+132);
ERROR_PPP_CP_REJECTED = (RASBASE+133);
ERROR_PPP_LCP_TERMINATED = (RASBASE+134);
ERROR_PPP_REQUIRED_ADDRESS_REJECTED = (RASBASE+135);
ERROR_PPP_NCP_TERMINATED = (RASBASE+136);
ERROR_PPP_LOOPBACK_DETECTED = (RASBASE+137);
ERROR_PPP_NO_ADDRESS_ASSIGNED = (RASBASE+138);
ERROR_CANNOT_USE_LOGON_CREDENTIALS = (RASBASE+139);
ERROR_TAPI_CONFIGURATION = (RASBASE+140);
ERROR_NO_LOCAL_ENCRYPTION = (RASBASE+141);
ERROR_NO_REMOTE_ENCRYPTION = (RASBASE+142);
ERROR_REMOTE_REQUIRES_ENCRYPTION = (RASBASE+143);
ERROR_IPXCP_NET_NUMBER_CONFLICT = (RASBASE+144);
ERROR_INVALID_SMM = (RASBASE+145);
ERROR_SMM_UNINITIALIZED = (RASBASE+146);
ERROR_NO_MAC_FOR_PORT = (RASBASE+147);
ERROR_SMM_TIMEOUT = (RASBASE+148);
ERROR_BAD_PHONE_NUMBER = (RASBASE+149);
ERROR_WRONG_MODULE = (RASBASE+150);

RASBASEEND = (RASBASE+150);

const
RAS_MaxAreaCode = 10;
RAS_MaxPadType = 32;
RAS_MaxX25Address = 200;
RAS_MaxFacilities = 200;
RAS_MaxUserData = 200;

type
(* RAS IP Address *)
LPRasIPAddr = ^TRasIPAddr;
TRasIPAddr = record
A, B, C, D: Byte;
end;

(* RAS phonebook entry *)
LPRasEntryA = ^TRasEntryA;
TRasEntryA = record
dwSize,
dwfOptions,
dwCountryID,
dwCountryCode : Longint;
szAreaCode : array[0.. RAS_MaxAreaCode] of AnsiChar;
szLocalPhoneNumber : array[0..RAS_MaxPhoneNumber] of AnsiChar;
dwAlternatesOffset : Longint;
ipaddr,
ipaddrDns,
ipaddrDnsAlt,
ipaddrWins,
ipaddrWinsAlt : TRasIPAddr;
dwFrameSize,
dwfNetProtocols,
dwFramingProtocol : Longint;
szScript : Array[0..MAX_PATH - 1] of AnsiChar;
szAutodialDll : Array [0..MAX_PATH - 1] of AnsiChar;
szAutodialFunc : Array [0..MAX_PATH - 1] of AnsiChar;
szDeviceType : Array [0..RAS_MaxDeviceType] of AnsiChar;
szDeviceName : Array [0..RAS_MaxDeviceName] of AnsiChar;
szX25PadType : Array [0..RAS_MaxPadType] of AnsiChar;
szX25Address : Array [0..RAS_MaxX25Address] of AnsiChar;
szX25Facilities : Array [0..RAS_MaxFacilities] of AnsiChar;
szX25UserData : Array [0..RAS_MaxUserData] of AnsiChar;
dwChannels,
dwReserved1,
dwReserved2 : Longint;
end;

LPRasEntryW = ^TRasEntryW;
TRasEntryW = record
dwSize,
dwfOptions,
dwCountryID,
dwCountryCode : Longint;
szAreaCode : array[0.. RAS_MaxAreaCode] of WideChar;
szLocalPhoneNumber : array[0..RAS_MaxPhoneNumber] of WideChar;
dwAlternatesOffset : Longint;
ipaddr,
ipaddrDns,
ipaddrDnsAlt,
ipaddrWins,
ipaddrWinsAlt : TRasIPAddr;
dwFrameSize,
dwfNetProtocols,
dwFramingProtocol : Longint;
szScript : Array[0..MAX_PATH - 1] of WideChar;
szAutodialDll : Array [0..MAX_PATH - 1] of WideChar;
szAutodialFunc : Array [0..MAX_PATH - 1] of WideChar;
szDeviceType : Array [0..RAS_MaxDeviceType] of WideChar;
szDeviceName : Array [0..RAS_MaxDeviceName] of WideChar;
szX25PadType : Array [0..RAS_MaxPadType] of WideChar;
szX25Address : Array [0..RAS_MaxX25Address] of WideChar;
szX25Facilities : Array [0..RAS_MaxFacilities] of WideChar;
szX25UserData : Array [0..RAS_MaxUserData] of WideChar;
dwChannels,
dwReserved1,
dwReserved2 : Longint;
end;

LPRasEntry = ^TRasEntry;
TRasEntry = TRasEntryA;

LPRasCtryInfo = ^TRasCtryInfo;
TRasCtryInfo = record
dwSize,
dwCountryID,
dwNextCountryID,
dwCountryCode,
dwCountryNameOffset : Longint;
end;

LPRasDevInfoA = ^TRasDevInfoA;
TRasDevInfoA = record
dwSize : Longint;
szDeviceType : Array[0..RAS_MaxDeviceType] of AnsiChar;
szDeviceName : Array[0..RAS_MaxDeviceName] of AnsiChar;
end;

LPRasDevInfoW = ^TRasDevInfoW;
TRasDevInfoW = record
dwSize : Longint;
szDeviceType : Array[0..RAS_MaxDeviceType] of WideChar;
szDeviceName : Array[0..RAS_MaxDeviceName] of WideChar;
end;

LPRasDevInfo = ^TRasDevInfo;
TRasDevInfo = TRasDevInfoA;

const
RASEO_UseCountryAndAreaCodes = $00000001;
RASEO_SpecificIpAddr = $00000002;
RASEO_SpecificNameServers = $00000004;
RASEO_IpHeaderCompression = $00000008;
RASEO_RemoteDefaultGateway = $00000010;
RASEO_DisableLcpExtensions = $00000020;
RASEO_TerminalBeforeDial = $00000040;
RASEO_TerminalAfterDial = $00000080;
RASEO_ModemLights = $00000100;
RASEO_SwCompression = $00000200;
RASEO_RequireEncryptedPw = $00000400;
RASEO_RequireMsEncryptedPw = $00000800;
RASEO_RequireDataEncryption = $00001000;
RASEO_NetworkLogon = $00002000;
RASEO_UseLogonCredentials = $00004000;
RASEO_PromoteAlternates = $00008000;

RASNP_Netbeui = $00000001; // Negotiate NetBEUI
RASNP_Ipx = $00000002; // Negotiate IPX
RASNP_Ip = $00000004; // Negotiate TCP/IP

RASFP_Ppp = $00000001; // Point-to-Point Protocol (PPP)
RASFP_Slip = $00000002; // Serial Line Internet Protocol (SLIP)
RASFP_Ras = $00000004; // Microsoft proprietary protocol

RASDT_Modem = 'modem'; // Modem
RASDT_Isdn = 'isdn'; // ISDN
RASDT_X25 = 'x25'; // X.25

function RasValidateEntryNameA(lpszPhonebook,szEntry: PAnsiChar): Longint; stdcall;
function RasValidateEntryNameW(lpszPhonebook,szEntry: PWideChar): Longint; stdcall;
function RasValidateEntryName(lpszPhonebook,szEntry: PAnsiChar): Longint; stdcall;

function RasRenameEntryA(lpszPhonebook,szEntryOld,szEntryNew: PAnsiChar): Longint; stdcall;
function RasRenameEntryW(lpszPhonebook,szEntryOld,szEntryNew: PWideChar): Longint; stdcall;
function RasRenameEntry(lpszPhonebook,szEntryOld,szEntryNew: PAnsiChar): Longint; stdcall;

function RasDeleteEntryA(lpszPhonebook,szEntry: PAnsiChar): Longint; stdcall;
function RasDeleteEntryW(lpszPhonebook,szEntry: PWideChar): Longint; stdcall;
function RasDeleteEntry(lpszPhonebook,szEntry: PAnsiChar): Longint; stdcall;

function RasGetEntryPropertiesA(lpszPhonebook, szEntry: PAnsiChar; lpbEntry: Pointer;
var lpdwEntrySize: Longint; lpbDeviceInfo: Pointer;
var lpdwDeviceInfoSize: Longint): Longint; stdcall;
function RasGetEntryPropertiesW(lpszPhonebook, szEntry: PWideChar; lpbEntry: Pointer;
var lpdwEntrySize: Longint; lpbDeviceInfo: Pointer;
var lpdwDeviceInfoSize: Longint): Longint; stdcall;
function RasGetEntryProperties(lpszPhonebook, szEntry: PAnsiChar; lpbEntry: Pointer;
var lpdwEntrySize: Longint; lpbDeviceInfo: Pointer;
var lpdwDeviceInfoSize: Longint): Longint; stdcall;

function RasSetEntryPropertiesA(lpszPhonebook, szEntry: PAnsiChar; lpbEntry: Pointer;
dwEntrySize: Longint; lpbDeviceInfo: Pointer;
dwDeviceInfoSize: Longint): Longint; stdcall;
function RasSetEntryPropertiesW(lpszPhonebook, szEntry: PWideChar; lpbEntry: Pointer;
dwEntrySize: Longint; lpbDeviceInfo: Pointer;
dwDeviceInfoSize: Longint): Longint; stdcall;
function RasSetEntryProperties(lpszPhonebook, szEntry: PAnsiChar; lpbEntry: Pointer;
dwEntrySize: Longint; lpbDeviceInfo: Pointer;
dwDeviceInfoSize: Longint): Longint; stdcall;

function RasGetCountryInfoA(var lpCtryInfo: TRasCtryInfo;var lpdwSize: Longint): Longint; stdcall;
function RasGetCountryInfoW(var lpCtryInfo: TRasCtryInfo;var lpdwSize: Longint): Longint; stdcall;
function RasGetCountryInfo(var lpCtryInfo: TRasCtryInfo;var lpdwSize: Longint): Longint; stdcall;

function RasEnumDevicesA(lpBuff: LpRasDevInfoA; var lpcbSize: Longint;
var lpcDevices: Longint): Longint; stdcall;
function RasEnumDevicesW(lpBuff: LpRasDevInfoW; var lpcbSize: Longint;
var lpcDevices: Longint): Longint; stdcall;
function RasEnumDevices(lpBuff: LpRasDevInfo; var lpcbSize: Longint;
var lpcDevices: Longint): Longint; stdcall;

const MaxEntries = 256;

type

TOnEntryGet = procedure (Sender : TObject; EntryName : Array of {Ansi}Char) of Object;
TStandartEv = procedure (Sender : TObject) of object;
TOnNotConn = procedure (Sender : TObject; ErrorCode : Integer; ErrorMessage : String) of object;
TOnAsyncEvent = procedure (Sender : TObject; State : TRasConnState; Error : Integer;
MessageText : String) of object;
TOnError = procedure (Sender : TObject; ErrorCode : Integer; ErrorMessage : String) of Object;
TOnActiveConn = procedure (Sender : TObject; Handle : THRasConn; Status : TRasConnStatus;
StatusString : String;
EntryName, DeviceType, DeviceName : Array of Char) of object;

TDialMode = (dmAsync,dmSync);

TDialUp = class(TComponent)
private
FEntries : TStringList;
FDialMode : TDialMode;
FEntry2Dial : String;

FTimer : TTimer;

FOnEntryGet : TOnEntryGet;
FOnDialing, FOnConnected : TStandartEv;
FOnNotConnected : TOnNotConn;
FOnAsyncEvent : TOnAsyncEvent;
FOnError : TOnError;
FOnActiveConn : TOnActiveConn;

protected
procedure Timer(Sender: TObject); virtual;

public
hRAS : ThRASConn;
AsyncStatus : Boolean;
AMsg,AError : Integer;
AState : TRasConnState;

constructor Create(AOwner:TComponent); override;
destructor Destroy; override;
function Dial : Integer;
function GetEntries : Integer;
function GetConnections : Integer;
function HangUp : Integer;
function HangUpConn(Handle : THRasConn) : Integer;
function CreateEntry : Integer;
function EditEntry : Integer;
function DeleteEntry : Integer;
function RenameEntryTo(S : String) : Integer;
function SetEntryUserName(Value : String) : Integer;
function SetEntryPassword(Value : String) : Integer;
function RemovePassword : Integer;
function GetEntryUserName(var Value : String) : Integer;
function GetEntryPassword(var Value : String) : Integer;
function StatusString(State: TRasConnState; Error: Integer): String;

published
property Name;
property Tag;
property DialMode : TDialMode read FDialMode write FDialMode;
property Entries : TStringList read FEntries;
property Entry : String read FEntry2Dial write FEntry2Dial;
property OnEntryGet : TOnEntryGet read FOnEntryGet write FOnEntryGet;
property OnDialing : TStandartEv read FOnDialing write FOnDialing;
property OnConnect : TStandartEv read FOnConnected write FOnConnected;
property OnNotConnected : TOnNotConn read FOnNotConnected write FOnNotConnected;
property OnAsyncEvent : TOnAsyncEvent read FOnAsyncEvent write FOnAsyncEvent;
property OnError : TOnError read FOnError write FOnError;
property OnActiveConnection : TOnActiveConn read FOnActiveConn write FOnActiveConn;

end;

procedure Register;

implementation

var xSelf : Pointer;

procedure TDialUp.Timer(Sender: TObject);
begin
FTimer.Enabled:=False;
if AsyncStatus=False then Exit;
if Assigned(FOnAsyncEvent) then FOnAsyncEvent(Self,AState,AError,StatusString(AState, AError));
AsyncStatus:=False;
end;

procedure RasCallback(msg: Integer; state: TRasConnState;
error: Integer); stdcall;
begin
While TDialUp(xSelf).AsyncStatus=True do ;
TDialUp(xSelf).AsyncStatus:=True;
TDialUp(xSelf).AMsg:=Msg;
TDialUp(xSelf).AState:=State;
TDialUp(xSelf).AError:=Error;
TDialUp(xSelf).FTimer.Enabled:=True;
end;

procedure Register;
begin
RegisterComponents('Internet',[TDialUp]);
end;

constructor TDialUp.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
AsyncStatus:=False;
FEntries:=TStringList.Create;
FTimer:=TTimer.Create(Self);
FTimer.Enabled:=False; FTimer.Interval:=1;
FTimer.OnTimer:=Timer;
end;


{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

destructor TDialUp.Destroy;
begin
inherited Destroy;
FEntries.Free;
end;


{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

Function TDialUp.Dial : Integer;
var
Fp : LongBool;
R : Integer;
C : Array[0..100] of Char;
ErrS : String;
DialParams : TRasDialParams;

begin
HangUp;

FillChar(DialParams, SizeOf(TRasDialParams), 0);
with DialParams do
begin
dwSize:=Sizeof(TRasDialParams);
StrPCopy(szEntryName, FEntry2Dial);
end;

R:=RasGetEntryDialParams(nil, DialParams, Fp);
if R<>0 then
begin
Result:=R;
if Assigned(FOnError) then FOnError(Self,R,'GetEntryDialParams failed');
Exit;
end;

hRAS:=0;
if DialMode=dmSync then // Synchronous dial
begin
if Assigned(FOnDialing) then FOnDialing(Self);
R:=RasDial(nil, nil, DialParams, 0, nil, hRAS);
if R=0 then
begin
if Assigned(FOnConnected) then
FOnConnected(Self)
end else
begin
if hRas<>0 then
RasHangUp(hRas);
RasGetErrorString(R, C, 100); ErrS:=C;
if Assigned(FOnNotConnected) then FOnNotConnected(Self,R,ErrS);
end;
end else // Asynchronous dial

begin
// Async dial
xSelf:=Self;
if Assigned(FOnDialing) then FOnDialing(Self);
R:=RasDial(nil, nil, DialParams, 0, @RasCallback, hRAS);
if R<>0 then
begin
RasGetErrorString(R,C,100);
if Assigned(FOnError) then FOnError(Self,R,C);
end;
end;
Result:=R;
end;


{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

Function TDialUp.GetEntries : Integer;
var
BuffSize : Integer;
Entries : Integer;
Entry : Array[1..MaxEntries] of TRasEntryName;
X,Result_ : Integer;
begin
Result:=0;
FEntries.Clear;
Entry[1].dwSize:=SizeOf(TRasEntryName);
BuffSize:=SizeOf(TRasEntryName)*MaxEntries;
Result_:=RasEnumEntries(nil, nil, @Entry[1], BuffSize, Entries);
if (Result_=0) and (Entries>0) then
begin
for X:=1 to Entries do
begin
FEntries.Add(Entry[x].szEntryName);
If Assigned(FOnEntryGet) then FOnEntryGet(Self,Entry[x].szEntryName);
end;
end else
Result:=Result_;
end;


{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

Function TDialUp.GetConnections : Integer;
var
BufSize : Integer;
NumEntries : Integer;
X : Integer;
Entries : Array[1..MaxEntries] of TRasConn;
Stat : TRasConnStatus;
Result_ : Integer;
S : String;
begin
Result:=0;

Entries[1].dwSize := SizeOf(TRasConn);
Bufsize:=SizeOf(TRasConn)*MaxEntries;
FillChar(Stat, Sizeof(TRasConnStatus), 0);
Stat.dwSize:=Sizeof(TRasConnStatus);

Result_:=RasEnumConnections(@Entries[1], BufSize, NumEntries);
if Result_=0 then
begin
if NumEntries > 0 then

for X:=1 to NumEntries do
begin
RasGetConnectStatus(Entries[X].HRasConn, Stat);
S:=StatusString(Stat.RasConnState, Stat.dwError);
if Assigned(FOnActiveConn) then FOnActiveConn(Self, Entries[X].HRasConn,
Stat, S,
Entries[X].szEntryName,
Entries[X].szDeviceType,
Entries[X].szDeviceName);
end;
end else Result:=Result_;
end;


{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

Function TDialUp.HangUp : Integer;
begin
Result:=RasHangUp(hRas);
end;


{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

Function TDialUp.HangUpConn(Handle : THRasConn) : Integer;
begin
Result:=RasHangUp(Handle);
end;


{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}


Function TDialUp.CreateEntry : Integer;
begin
if (Owner is TForm) then
Result:=RasCreatePhonebookEntry((Owner as TForm).Handle, nil) else
Result:=RasCreatePhonebookEntry(0, nil);
end;


{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

Function TDialUp.EditEntry : Integer;
begin
if (Owner is TForm) then
Result:=RasEditPhonebookEntry((Owner as TForm).Handle, nil, PChar(FEntry2Dial)) else
Result:=RasEditPhonebookEntry(0, nil, PChar(FEntry2Dial));
end;

{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

Function TDialUp.RenameEntryTo(S : String) : Integer;
begin
Result:=RasRenameEntry(nil, PChar(FEntry2Dial), PChar(S));
end;

{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

Function TDialUp.DeleteEntry : Integer;
begin
Result:=RasDeleteEntry(nil, PChar(FEntry2Dial))
end;


{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

function TDialUp.SetEntryUserName(Value : String) : Integer;
var DialParams : TRasDialParams;
begin
with DialParams do
begin
dwSize:=Sizeof(TRasDialParams);
StrPCopy(szEntryName, PChar(FEntry2Dial));
StrPCopy(szUserName, Value);
end;
Result:=RasSetEntryDialParams(nil, DialParams, False);
end;

{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

function TDialUp.SetEntryPassword(Value : String) : Integer;
var DialParams : TRasDialParams;
begin
with DialParams do
begin
dwSize:=Sizeof(TRasDialParams);
StrPCopy(szEntryName, PChar(FEntry2Dial));
StrPCopy(szPassword, Value);
end;
Result:=RasSetEntryDialParams(nil, DialParams, False);
end;

{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

function TDialUp.RemovePassword : Integer;
var DialParams : TRasDialParams;
begin
with DialParams do
begin
dwSize:=Sizeof(TRasDialParams);
StrPCopy(szEntryName, PChar(FEntry2Dial));
end;
Result:=RasSetEntryDialParams(nil, DialParams, True);
end;

{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

function TDialUp.GetEntryUserName(var Value : String) : Integer;
var
Fp : LongBool;
R : Integer;
// C : Array[0..100] of Char;
DialParams : TRasDialParams;
begin
FillChar(DialParams, SizeOf(TRasDialParams), 0);
with DialParams do
begin
dwSize:=Sizeof(TRasDialParams);
StrPCopy(szEntryName, FEntry2Dial);
end;
R:=RasGetEntryDialParams(nil, DialParams, Fp);
if R=0 then
with DialParams do
begin
Value:=szUserName;
end;
Result:=R;
end;

{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

function TDialUp.GetEntryPassword(var Value : String) : Integer;
var
Fp : LongBool;
R : Integer;
// C : Array[0..100] of Char;
DialParams : TRasDialParams;
begin
FillChar(DialParams, SizeOf(TRasDialParams), 0);
with DialParams do
begin
dwSize:=Sizeof(TRasDialParams);
StrPCopy(szEntryName, FEntry2Dial);
end;
R:=RasGetEntryDialParams(nil, DialParams, Fp);
if R=0 then
with DialParams do
begin
if Fp then
Value:=szPassword else Value:='';
end;
Result:=R;
end;

{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

function TDialUp.StatusString(State: TRasConnState; Error: Integer): String;
var
C : Array[0..100] of Char;
S : String;
begin
if Error<>0 then
begin
RasGetErrorString(Error, C, 100);
Result:=C;
end else
begin
S:='';
case State of
RASCS_OpenPort:
S:='Opening port';
RASCS_PortOpened:
S:='Port opened';
RASCS_ConnectDevice:
S:='Connecting device';
RASCS_DeviceConnected:
S:='Device connected';
RASCS_AllDevicesConnected:
S:='All devices connected';
RASCS_Authenticate:
S:='Start authenticating';
RASCS_AuthNotify:
S:='Authentication: notify';
RASCS_AuthRetry:
S:='Authentication: retry';
RASCS_AuthCallback:
S:='Authentication: callback';
RASCS_AuthChangePassword:
S:='Authentication: change password';
RASCS_AuthProject:
S:='Authentication: projecting';
RASCS_AuthLinkSpeed:
S:='Authentication: link speed';
RASCS_AuthAck:
S:='Authentication: acknowledge';
RASCS_ReAuthenticate:
S:='Authentication: reauthenticate';
RASCS_Authenticated:
S:='Authenticated';
RASCS_PrepareForCallback:
S:='Preparing for callback';
RASCS_WaitForModemReset:
S:='Waiting for modem reset';
RASCS_WaitForCallback:
S:='Waiting for callback';
RASCS_Projected:
S:='Projected';
RASCS_StartAuthentication:
S:='Start authentication';
RASCS_CallbackComplete:
S:='Callback complete';
RASCS_LogonNetwork:
S:='Logging on network';

RASCS_Interactive:
S:='Interactive';
RASCS_RetryAuthentication:
S:='Retry Authentication';
RASCS_CallbackSetByCaller:
S:='Callback set by caller';
RASCS_PasswordExpired:
S:='Password expired';

RASCS_Connected:
S:='Connected';
RASCS_Disconnected:
S:='Disconnected';
end;
Result:=S;
end;
end;

function RasCreatePhonebookEntryA; external 'rasapi32.dll' name 'RasCreatePhonebookEntryA';
function RasCreatePhonebookEntryW; external 'rasapi32.dll' name 'RasCreatePhonebookEntryW';
function RasCreatePhonebookEntry; external 'rasapi32.dll' name 'RasCreatePhonebookEntryA';
function RasDialA; external 'rasapi32.dll' name 'RasDialA';
function RasDialW; external 'rasapi32.dll' name 'RasDialW';
function RasDial; external 'rasapi32.dll' name 'RasDialA';
function RasEditPhonebookEntryA; external 'rasapi32.dll' name 'RasEditPhonebookEntryA';
function RasEditPhonebookEntryW; external 'rasapi32.dll' name 'RasEditPhonebookEntryW';
function RasEditPhonebookEntry; external 'rasapi32.dll' name 'RasEditPhonebookEntryA';
function RasEnumConnectionsA; external 'rasapi32.dll' name 'RasEnumConnectionsA';
function RasEnumConnectionsW; external 'rasapi32.dll' name 'RasEnumConnectionsW';
function RasEnumConnections; external 'rasapi32.dll' name 'RasEnumConnectionsA';
function RasEnumEntriesA; external 'rasapi32.dll' name 'RasEnumEntriesA';
function RasEnumEntriesW; external 'rasapi32.dll' name 'RasEnumEntriesW';
function RasEnumEntries; external 'rasapi32.dll' name 'RasEnumEntriesA';
function RasGetConnectStatusA; external 'rasapi32.dll' name 'RasGetConnectStatusA';
function RasGetConnectStatusW; external 'rasapi32.dll' name 'RasGetConnectStatusW';
function RasGetConnectStatus; external 'rasapi32.dll' name 'RasGetConnectStatusA';
function RasGetEntryDialParamsA; external 'rasapi32.dll' name 'RasGetEntryDialParamsA';
function RasGetEntryDialParamsW; external 'rasapi32.dll' name 'RasGetEntryDialParamsW';
function RasGetEntryDialParams; external 'rasapi32.dll' name 'RasGetEntryDialParamsA';
function RasGetErrorStringA; external 'rasapi32.dll' name 'RasGetErrorStringA';
function RasGetErrorStringW; external 'rasapi32.dll' name 'RasGetErrorStringW';
function RasGetErrorString; external 'rasapi32.dll' name 'RasGetErrorStringA';
function RasGetProjectionInfoA; external 'rasapi32.dll' name 'RasGetProjectionInfoA';
function RasGetProjectionInfoW; external 'rasapi32.dll' name 'RasGetProjectionInfoW';
function RasGetProjectionInfo; external 'rasapi32.dll' name 'RasGetProjectionInfoA';
function RasHangUpA; external 'rasapi32.dll' name 'RasHangUpA';
function RasHangUpW; external 'rasapi32.dll' name 'RasHangUpW';
function RasHangUp; external 'rasapi32.dll' name 'RasHangUpA';
function RasSetEntryDialParamsA; external 'rasapi32.dll' name 'RasSetEntryDialParamsA';
function RasSetEntryDialParamsW; external 'rasapi32.dll' name 'RasSetEntryDialParamsW';
function RasSetEntryDialParams; external 'rasapi32.dll' name 'RasSetEntryDialParamsA';
function RasValidateEntryNameA; external 'rasapi32.dll' name 'RasValidateEntryNameA';
function RasValidateEntryNameW; external 'rasapi32.dll' name 'RasValidateEntryNameW';
function RasRenameEntryA; external 'rasapi32.dll' name 'RasRenameEntryA';
function RasRenameEntryW; external 'rasapi32.dll' name 'RasRenameEntryW';
function RasDeleteEntryA; external 'rasapi32.dll' name 'RasDeleteEntryA';
function RasDeleteEntryW; external 'rasapi32.dll' name 'RasDeleteEntryW';
function RasGetEntryPropertiesA; external 'rasapi32.dll' name 'RasGetEntryPropertiesA';
function RasGetEntryPropertiesW; external 'rasapi32.dll' name 'RasGetEntryPropertiesW';
function RasSetEntryPropertiesA; external 'rasapi32.dll' name 'RasSetEntryPropertiesA';
function RasSetEntryPropertiesW; external 'rasapi32.dll' name 'RasSetEntryPropertiesW';
function RasGetCountryInfoA; external 'rasapi32.dll' name 'RasGetCountryInfoA';
function RasGetCountryInfoW; external 'rasapi32.dll' name 'RasGetCountryInfoW';
function RasEnumDevicesA; external 'rasapi32.dll' name 'RasEnumDevicesA';
function RasEnumDevicesW; external 'rasapi32.dll' name 'RasEnumDevicesW';

var
Rnaph_Initialized : Boolean = False;
Is_Rnaph : Boolean = False;
Lib : HModule;

function Rnaph_(const func: String): Pointer;
begin
if not Rnaph_Initialized then
begin
Lib:=LoadLibrary('rasapi32.dll');
if Lib<>0 then
begin
Result:=GetProcAddress(Lib, PChar(Func+'A'));
if Result<>nil then
begin
Rnaph_Initialized:=True;
Exit;
end;
end else raise Exception.Create('Error opening rasapi.dll');
Lib:=LoadLibrary('rnaph.dll');
if Lib<>0 then
begin
Result:=GetProcAddress(Lib, PChar(Func));
if Result <> nil then
begin
Rnaph_Initialized:=True;
Is_Rnaph:=True;
Exit;
end else raise Exception.Create('Function '+Func+' not found!');
end else raise Exception.Create('Error opening rnaph.dll');
end else
begin
if Is_Rnaph then Result:=GetProcAddress(Lib,PChar(Func))
else Result:=GetProcAddress(lib,PChar(Func+'A'));
if Result=nil then raise Exception.Create('Function '+Func+' not found!');
end;
end;

function RasValidateEntryName(lpszPhonebook, szEntry: PAnsiChar): Longint;
var
F : Function(lpszPhonebook, szEntry: PAnsiChar): Longint; stdcall;
begin
@F:=Rnaph_('RasValidateEntryName');
Result:=F(lpszPhonebook, szEntry);
end;

function RasRenameEntry(lpszPhonebook, szEntryOld, szEntryNew: PAnsiChar): Longint;
var
F : function(lpszPhonebook, szEntryOld, szEntryNew: PAnsiChar): Longint; stdcall;
begin
@F:=rnaph_('RasRenameEntry');
Result:=F(lpszPhonebook, szEntryOld, szEntryNew);
end;

function RasDeleteEntry(lpszPhonebook, szEntry: PAnsiChar): Longint;
var
F : function(lpszPhonebook, szEntry: PAnsiChar): Longint; stdcall;
begin
@F:=Rnaph_('RasDeleteEntry');
Result:=F(lpszPhonebook, szEntry);
end;

function RasGetEntryProperties(lpszPhonebook, szEntry: PAnsiChar; lpbEntry: Pointer;
var lpdwEntrySize: Longint; lpbDeviceInfo: Pointer;
var lpdwDeviceInfoSize: Longint): Longint;
var
F : function(lpszPhonebook, szEntry: PAnsiChar; lpbEntry: Pointer;
lpdwEntrySize : Longint;
lpbDeviceInfo : Pointer;
lpdwDeviceInfoSize : Longint): Longint; stdcall;
begin
@F:=Rnaph_('RasGetEntryProperties');
Result:=F(lpszPhonebook, szEntry, lpbEntry, lpdwEntrySize, lpbDeviceInfo, lpdwDeviceInfoSize);
end;

function RasSetEntryProperties(lpszPhonebook, szEntry: PAnsiChar;
lpbEntry: Pointer; dwEntrySize: Longint; lpbDeviceInfo: Pointer;
dwDeviceInfoSize: Longint): Longint;
var
F : function(lpszPhonebook, szEntry: PAnsiChar;
lpbEntry: Pointer; dwEntrySize: Longint;
lpbDeviceInfo: Pointer;
dwDeviceInfoSize: Longint): Longint; stdcall;
begin
@F:=Rnaph_('RasSetEntryProperties');
Result:=F(lpszPhonebook, szEntry, lpbEntry, dwEntrySize, lpbDeviceInfo, dwDeviceInfoSize);
end;


function RasGetCountryInfo(var lpCtryInfo: TRasCtryInfo; var lpdwSize: Longint): Longint;
var
F : function(var lpCtryInfo: TRasCtryInfo;
var lpdwSize: Longint): Longint; stdcall;
begin
@F:=Rnaph_('RasGetCountryInfo');
Result:=F(lpCtryInfo, lpdwSize);
end;


function RasEnumDevices(lpBuff: LpRasDevInfo; var lpcbSize: Longint;
var lpcDevices: Longint): Longint;
var
F : function(lpBuff: LpRasDevInfo; var lpcbSize: Longint;
var lpcDevices: Longint): Longint; stdcall;
begin
@F:=Rnaph_('RasEnumDevices');
Result:=F(lpBuff, lpcbSize, lpcDevices);
end;


initialization

finalization
if Rnaph_initialized and Is_rnaph then FreeLibrary(lib);
end.

 
to panzichan:
谢谢你的回复,但,您帖的是什么啊?我说的是加密算法Rsa的delphi实现的源码!
这毫不相干啊。
 
呵呵,他给是RAS,哈哈~~~~
 
对不起,我找了很久,但是还是没有找到。我记得曾经保存在硬盘上的,但找了半天
哪里也没有(不知是不是重装系统时忘了备份),而原来保存这些内容的光盘也不知
放到哪里去了,也没有找到。

不好意思,等我找到后再发给兄弟们吧。Sorry!
 
我找到了!
先贴出部分源代码,稍后给各位发送详细的例子到各位兄弟的信箱。
//RSA的加密和解密函数,等价于(m^e) mod n(即m的e次幂对n求余)
function Encrypt_Decrypt(m: Int64; e: Int64=$2C86F9; n: Int64=$69AAA0E3): Int64;
var
a, b, c: Int64;
begin
a:=m;
b:=e;
c:=1;
while b<>0 do
if (b mod 2)=0 then begin
b:=b div 2;
a:=(a * a) mod n;
end else begin
b:=b - 1;
c:=(a * c) mod n;
end;
Result:=c;
end;
 
邮件已经发送,请大家注意查收!
 
to zqw0117:老兄,也给我发一份吧,我为这个问题找了好久了,我的信箱:tqc2008@963.net,谢谢!
 
各位大虾:谁收到了zqw0117发送的Demo了,请给小弟发送一份,信箱:tqc2008@963.net,谢谢!
 
这是什么东东呀?介绍一下,也给我一份吧,谢谢。mdc1975@21cn.com
 
后退
顶部