R
rejoise
Unregistered / Unconfirmed
GUEST, unregistred user!
我想实现最简单的拨号,拨号连接名为‘1’,编译通过,但运行出错,请大虾看看
如何修改我的代码。另请提供给我一个RAS控件,给出地址或发至sension@etang.com
谢谢大虾!原代码如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
Const
UNLEN = 256;
PWLEN = 256;
DNLEN = 15;
RAS_MaxEntryName = 256;
RAS_MaxDeviceName = 128;
RAS_MaxDeviceType = 16;
RAS_MaxPhoneNumber = 128;
RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;
Type
PHRASConn = ^HRASConn;
HRASConn = DWORD;
Type
PRASConn = ^TRASConn;
TRASConn = record
dwSize: DWORD;
rasConn: HRASConn;
szEntryName: Array[0..RAS_MaxEntryName] Of Char;
szDeviceType : Array[0..RAS_MaxDeviceType] Of Char;
szDeviceName : Array [0..RAS_MaxDeviceName] of char;
end;
PRASConnStatus = ^TRASConnStatus;
TRASConnStatus = Record
dwSize: LongInt;
rasConnstate: Word;
dwError: LongInt;
szDeviceType: Array[0..RAS_MaxDeviceType] Of Char;
szDeviceName: Array[0..RAS_MaxDeviceName] Of Char;
End;
PRASDIALEXTENSIONS= ^TRASDIALEXTENSIONS;
TRASDIALEXTENSIONS= Record
dwSize: DWORD;
dwfOptions: DWORD;
hwndParent: HWnd;
reserved: DWORD;
end;
PRASDialParams = ^TRASDialParams;
TRASDialParams = 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;
end;
PRASEntryName = ^TRASEntryName;
TRASEntryName = Record
dwSize: LongInt;
szEntryName: Array[0..RAS_MaxEntryName] Of Char;
// Reserved: Byte;
End;
var
Form1: TForm1;
Function RasDial(
lpRasDialExtensions : PRASDIALEXTENSIONS ;
lpszPhonebook: PChar;
lpRasDialParams : PRASDIALPARAMS;
dwNotifierType : DWORD;
lpvNotifier: DWORD;
var rasConn: HRASConn): DWORD; stdcall;
implementation
const
RAS_DLL = 'RASAPI32';
function RasDial; external RAS_DLL name 'RasDialA';
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
iRASDIALPARAMS;
j:HRASConn;
begin
i.dwSize:=sizeof(PRASDIALPARAMS);
i.szEntryName[0]:='1';
i.szUserName[0]:='0' ;
i.szPassword[0]:='0';
j:=0;
rasdial(nil,nil,i,0,0,j);
end;
end.
如何修改我的代码。另请提供给我一个RAS控件,给出地址或发至sension@etang.com
谢谢大虾!原代码如下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
Const
UNLEN = 256;
PWLEN = 256;
DNLEN = 15;
RAS_MaxEntryName = 256;
RAS_MaxDeviceName = 128;
RAS_MaxDeviceType = 16;
RAS_MaxPhoneNumber = 128;
RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;
Type
PHRASConn = ^HRASConn;
HRASConn = DWORD;
Type
PRASConn = ^TRASConn;
TRASConn = record
dwSize: DWORD;
rasConn: HRASConn;
szEntryName: Array[0..RAS_MaxEntryName] Of Char;
szDeviceType : Array[0..RAS_MaxDeviceType] Of Char;
szDeviceName : Array [0..RAS_MaxDeviceName] of char;
end;
PRASConnStatus = ^TRASConnStatus;
TRASConnStatus = Record
dwSize: LongInt;
rasConnstate: Word;
dwError: LongInt;
szDeviceType: Array[0..RAS_MaxDeviceType] Of Char;
szDeviceName: Array[0..RAS_MaxDeviceName] Of Char;
End;
PRASDIALEXTENSIONS= ^TRASDIALEXTENSIONS;
TRASDIALEXTENSIONS= Record
dwSize: DWORD;
dwfOptions: DWORD;
hwndParent: HWnd;
reserved: DWORD;
end;
PRASDialParams = ^TRASDialParams;
TRASDialParams = 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;
end;
PRASEntryName = ^TRASEntryName;
TRASEntryName = Record
dwSize: LongInt;
szEntryName: Array[0..RAS_MaxEntryName] Of Char;
// Reserved: Byte;
End;
var
Form1: TForm1;
Function RasDial(
lpRasDialExtensions : PRASDIALEXTENSIONS ;
lpszPhonebook: PChar;
lpRasDialParams : PRASDIALPARAMS;
dwNotifierType : DWORD;
lpvNotifier: DWORD;
var rasConn: HRASConn): DWORD; stdcall;
implementation
const
RAS_DLL = 'RASAPI32';
function RasDial; external RAS_DLL name 'RasDialA';
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
iRASDIALPARAMS;
j:HRASConn;
begin
i.dwSize:=sizeof(PRASDIALPARAMS);
i.szEntryName[0]:='1';
i.szUserName[0]:='0' ;
i.szPassword[0]:='0';
j:=0;
rasdial(nil,nil,i,0,0,j);
end;
end.