procedure TRasDialerForm.Dial(EntryName, UserName, Password : String);
var
rdParams : TRASDIALPARAMS;
dwRet : DWORD;
Buf : array [0..255] of Char;
begin
hRasConn := GetActiveConnHandle(EntryName);
if hRasConn <> 0 then begin
LogMessage('Connection already active');
Connected;
ConnectTime := $FFFFFFFF;
Exit;
end;
// setup RAS Dial Parameters
FillChar(rdParams, SizeOf(rdParams), 0);
rdParams.dwSize := SizeOf(TRASDIALPARAMS);
strCopy(rdParams.szUserName, PChar(UserName));
strCopy(rdParams.szPassword, PChar(Password));
strCopy(rdParams.szEntryName, PChar(EntryName));
rdParams.szPhoneNumber[0] := #0;
rdParams.szCallbackNumber[0] := '*';
rdParams.szDomain := '*';
g_hWnd := Handle;
hRasConn := 0;;
dwRet := RasDialA(nil, nil, @rdParams, 0, @RasDialFunc, @hRasConn);
if dwRet <> 0 then begin
RasGetErrorStringA(dwRet, @Buf[0], SizeOf(Buf));
LogMessage(IntToStr(dwRet) + ' ' + Buf);
Disconnected;
end
else begin
LogMessage('Dialing ''' + EntryName + '''');
CancelButton.Enabled := TRUE;
MnuCancel.Enabled:=TRUE;
ConnectButton.Enabled := FALSE;
MnuDialUp.Enabled:=FALSE;
end;
end;