Do not call Dial-Up Networking in programs

Source: Internet
Author: User
Tags error code function prototype

The RASAPI function used to dial the dial-up connection is rasdial, and its function prototype is:

function RasDial (prasdialextensions:lprasdialextensions;//is useless under Win9x and can be set to nil

lpszphonebook:pchar;//phone name, no action under Win9x, can be an empty string

lprasdialparams:lprasdialparams;//Dialing Parameters

DWNOTIFIERTYPE:DWORD;//Message Notification method

handle:trasdialfunc;//Message Handling Events

Connection handle for successful connection returned by Var lphrasconn:dword//

): DWORD; stdcall;

function rasdial;external rasapidll name ' Rasdiala ';

The description of the parameter Prasdialparams with the Rasgetentrydialparams.

The parameter dwnotifiertype represents the message notification method. During the dialing process, the system issues a dial-up event message that notifies you of the dialing progress, and therefore needs to provide a way to accept the message and a function to process the message. When its value is $FFFFFFFF, the parameter handle is treated as a handle to a window, the event message is processed by the window, and when its value is 0 o'clock, handle is treated as a pointer to a function of the trasdialfunc type; when its value is 1 o'clock, Handle a pointer to a function that is considered a TRasDialFunc1 type.

The parameter handle represents the message handler function pointer whose type can be Thandle, Trasdialfunc, TRasDialFunc1. When the parameter is not NULL or nil, the message handler function pointer that it represents will accept the dialing progress notification message, and when nil, the dialing process becomes synchronized asynchronously until the Rasdial function returns after the dial-up process succeeds or fails. See the Delphi help file for help on the rasdial function in detail.

When a dial-up connection succeeds, Lphrasconn will represent its connection handle.

A function return value of 0 indicates successful execution; otherwise, it is an error code.

The following is an example of an application that dials by the specified dialing parameter.

var
RASDIALPARAMSData : RASDIALPARAMS;
dwResult : DWord;
RasCon : DWord;
begin
//指定拨号连接的拨号参数
with RASDIALPARAMSData do
begin
dwSize := sizeof( RASDIALPARAMS );//结构大小
szEntryName := '163';//指定拨号连接的名称
szUserName := 'MyName';//指定用户名称
szPassword := 'MyPassword';//指定用户密码
szDomain := 'MyDomain';//指定域名
szCallbackNumber := '';//指定回叫号码
szPhoneNumber := '';//指定拨号号码
end;
//用指定的拨号参数拨号,采用同步拨号方式
dwResult := RasDial( NIL,'',@RASDIALPARAMSData,0,NIL,RasCon
);
if dwResult < > 0 then //设置指定拨号连接的拨号参数失败
memo1.lines.add( '用'+StrPAS(RASDIALPARAMSData.szEntryName
)+'拨号失败:'
+ GetRasError( dwResult ))
else
memo1.lines.add( '用'+StrPAS(RASDIALPARAMSData.szEntryName
)+'拨号成功!' );
end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.