Use VC to realize the network dial function
Dalian Jietong Computer Technology Co., Ltd. Chen Hao
---- The current era is the era of the network, and the application of web applications is getting more and more extensive. Direct dial-up Internet access is implemented in their own application, bringing a lot of convenience to the application, this application is On the Chinese Windows95 operating system, the implementation of the Dial-Internet access is developed with VC 5.0, hoping to help everyone. Below is the source program that implements this feature:
---- First create a VC project based on dialog box, the following is a dialog box for this application (图))
---- Then add several new definition functions in the header file of the dialog box:
PUBLIC:
Void SetupDialupCombo (Void);
protected:
// {{AFX_MSG (CDIALPROCDLG)
Virtual Bool OnInitdialog ();
AFX_MSG void onConnectButton ();
// Responding to the "Continued" of the Button button in the dialog
AFX_MSG Void OnselchangeDialupCombo ();
/ / Responding to the event of the COMBO control in the conversation
//}} AFX_MSG
---- The following is the function of adding a new defined function in the source file of the dialog box: Don't forget to add #include in the header file
This header file, and librarymodules in the link in Settings Add Rasapi32.lib.
Void CDialProcdlg :: setupdialupcombo ()
{
m_dialcombo.ResetContent ();
// m_dialcombo is a naming of the Combox control in the dialog
DWORD N;
DWORD DWSIZE = 0;
// Enumerate all dial-up connections in the local computer.
DWord Ret = RaseNumentries
(NULL, NULL, NULL, & DWSIZE, & N);
n = dwsize / sizeof (rasentryname);
RasentryName * entry = new rasentryname [n];
IF (entry) {
Entry [0] .dwsize = sizeof (RasentryName);
DWord Ret = RaseNumentries
(NULL, NULL, Entry, & Dwsize, & n);
For (DWORD I = 0; I
= 0) {
m_dialcombo.getlbtext (sel, params.szentryname);
Trace ("% s / n", params.szentryname;
BOOL P;
RasgeTryDialParams (NULL, & PARAMS, & P);
m_userid.setwindowText (params.szusername);
m_passworddedit.setwindowText (params.szpassword);
}
}
Bool cDialProcdlg :: OnItDialog ()
{CDialog :: oninitdialog ();
SetupDialupCombo ();
Return true; // returntrue
UnsS you set the focus to a control
}
---- This application is developed, compiled, and running on VC 5.0 under the Chinese 95 operating system.