function DialConnect() : bool;
var
hRas: THRasConn;
dialparams: TRasDialParams;
r: integer;
c: Array[0..100] of Char;
dialOK: bool;
begin
dialOK := true;
FillChar(dialparams, SizeOf(TRasDialParams), 0);
with dialparams do
begin
dwSize := Sizeof(TRasDialParams);
StrPCopy(szEntryName, '拨号连接');
StrPCopy(szUserName, userName);
StrPCopy(szPassword, userKey);
// You can override phone number here...
// StrPCopy(szPhoneNumber, 'xxxxxx');
end;
Form1.StatusBar1.SimpleText := '正在拨号...';
hRas := 0;
r := RasDial(nil, // This field is ignored in Windows95
nil, // Phonebook: use default (not used on Win95)
dialparams,
0, // use callback function of type RASDIALFUNC
nil,//@RasCallback, // callback function
hRas);
if r <> 0 then
begin
dialOK := false;
RasGetErrorString(r, c, 100);
Form1.StatusBar1.SimpleText := '拨号连接失败: ' + c;
end
else
Form1.StatusBar1.SimpleText := '拨号已连接';
result := dialOK;
end;