VC实现PPPOE拨号

背景:代替手工自动进行PPPOE拨号

相关知识:

主要使用的函数:

The RasDial function establishes a RAS connection between a RAS client and a RAS server. The connection data includes callback and user-authentication information

DWORD RasDial(
__in LPRASDIALEXTENSIONS lpRasDialExtensions,
__in LPCTSTR lpszPhonebook,
__in LPRASDIALPARAMS lpRasDialParams,
__in DWORD dwNotifierType,
__in LPVOID lpvNotifier,
__in LPHRASCONN lphRasConn
);

Return Value

If the function succeeds, the return value is ERROR_SUCCESS and a handle to the RAS connection is returned in the variable pointed to by lphRasConn .

If the function fails, the return value is from Routing and Remote Access Error Codes or Winerror.h.

 

更多消息请查看 :

http://msdn.microsoft.com/en-us/library/aa377004(VS.85).aspx

 


    RASDIALPARAMS  ms;
    RASDIALPARAMS params;
    HRASCONN handle=NULL;   

    memset(&ms, '/0', sizeof(params));
    params.dwSize=sizeof(RASDIALPARAMS);

    CString entryname;
    CString tmp;
    tmp.Format("%d", i);
    entryname="UE"+tmp;//需要拨号的名称,也就是建立的宽带连接的名称,如UE0
    strcpy(params.szEntryName,entryname);

    strcpy(params.szPhoneNumber,"");
    strcpy(params.szCallbackNumber,"");

    strcpy(params.szUserName,"tm500");  //用户名
    strcpy(params.szPassword, "tm500");  //密码
    strcpy(params.szDomain,  ""); 

    Message +="/n"+entryname+"dailying up ......";
    UpdateData(TRUE);

   //指定的拨号连接。

    int a =RasDial(NULL, NULL, &params, NULL, NULL, &handle);
    if (a!=ERROR_SUCCESS)
    {
        MessageBox("正在拨打的计算机没有应答,稍后请再试");

        Message +="/n"+entryname+"dailying up failed....../n";
        UpdateData(TRUE);

        DWORD off=RasHangUp(handle);

        //SendMessage(WM_CLOSE);
         if (off==0)
        {
         MessageBox("连接已断开");
         //printf("连接已断开.../n");
        }
         else{
        //printf("断开连接出错.../n");
          MessageBox("断开连接出错.");
        }
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

惹不起的程咬金

来都来了,不赏点银子么

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值