Realize RAS dialing in the app

zhaozj2021-02-11  231

Realize RAS dialing in the app

Wang Tao

Remote Access Service (RAS) is one of the system services provided by the Windows NT operating system.

You can access a separate computer to the network through telephone line, or dial two RAS pairs.

LAN interconnection. The functionality of this service can make remote computer endpoints at a lower cost

Connect to the network.

Due to the large number of use of the Windows NT operating system, the remote access service function is also wide.

Inappropriate, in many specific applications, they have been implemented by remote access services.

Cheng's resource sharing and other functions. Continuous remote access service, as long as the remote client dialer

The network is OK, the execution hang is ended, and the mouse operation of Windows 9 5

The network can directly dial and hang up. But sometimes we want RAS in the app.

Dial and hang up to users are not visible, then the corresponding program control is required to implement RAS Dial

And hang up.

Windows 95 provides an API function rasdial, a dial-up network built in the system

Connect, complete the RAS dial, and also provides an API function rashangup disconnect connection. Rasd

The original shape of IAL is as follows:

DWord Rasdial (LPRASDIALEXTENSIONS iPRASDIALEXTENSIONS, LP

TSTR Ipszphonebo OK, LPRASDIALPARAMS IPRASDIALPARAMS, DWORD DW

Notifiertype, LPVOID IPVNOTIFIER, L Phrasconn iphrasconn)

The third parameter of this function is a pointer to the RasdialParams structure, which

For parameters for configuring RAS dial; the 5th parameter is the callback function executed after the dial completion;

6 parameters are lphrasconn-type pointers, which will return this after the dial-up connection is established.

Handle; other three parameters are null. Function call If successful will return zero, otherwise

Return the wrong code, the meaning of this error code can be checked in the header file Raserror.h.

The RasdialParams structure contains 7 data members: dwsize, szentryname

, Szphonenumber, SzcallbackNumber, SzuserName, Szpassword and S

ZDOMAIN, their role is as shown in the right.

To hang up the dialed connection to use the Rashangup function, the parameters required are this connection.

Connect the handle. Here is an example of using VC to complete the RAS dial, where we assume RA

The phone number of the internal integer connection of the S-terminal NT server is "22", the specific steps are as follows:

1. Configure the modem and build a one in the dial-up network of Windows 95.

Named Dial connection.

2. Create a Visual C application framework to join R in Setting

ASAPI32.LIB static library.

3. Create a dialog box, add two buttons, one for dial, one for

hang up.

4. Add the following code in the response function of the Mouse click the Dial button:

RasdialParams Rdparams;

DWORD DWRET;

Rdparams.dwsize = sizeof (rasdialparams);

STRCPY (RDParams.SzENTRYNAME, "DIAL");

STRCPY (rdparams.szphonenumber, "22");

Strcpy (rdparams.szcallbacknumber, "*");

Strcpy (rdparams.szusername, "dial");

Rdparams.szpassword = '/ 0';

STRCPY (RDParams.szdomain, "Dial");

Hrasconn = NULL;

DWRET = Rasdial (Null, Null, & Rdparams, 0L, (RasdialFunc) Rasdia

LFUNC, & HRASCONN)

IF (dwret! = 0) {

// deal with error ...

}

5. Add the following code before this response function:

Void WinAPI RasdialFunc (Uint

UNMSG, RasconnState RasconnState, DWORD DWERROR)

{

}

6. Add the following code in the response function of the mouse click the hanging button:

DWORD DWRET;

DWRET = rashangup (Hrasconn);

7. Final compilation executive.

Table 1 RasdialParams Structural Data Meter Table

(Author address: wangtaowt@yahoo.com)

转载请注明原文地址:https://www.9cbs.com/read-4015.html

New Post(0)