C#中怎么实现ADSL自动拨号

C#中怎么实现ADSL自动拨号,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

创新互联服务项目包括通辽网站建设、通辽网站制作、通辽网页制作以及通辽网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,通辽网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到通辽省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

C# ADSL自动拨号,前提是在系统中已经有了一个宽带拨号连接

C# ADSL自动拨号调用代码:

RASDisplayras=newRASDisplay();  ras.Disconnect();//断线  ras.Connect("adsl");//拨号    usingSystem;  usingSystem.Runtime.InteropServices;  publicstructRASCONN  {  publicintdwSize;  publicIntPtrhrasconn;  [MarshalAs(UnmanagedType.ByValTStr,SizeConst=257)]  publicstringszEntryName;  [MarshalAs(UnmanagedType.ByValTStr,SizeConst=17)]  publicstringszDeviceType;  [MarshalAs(UnmanagedType.ByValTStr,SizeConst=129)]  publicstringszDeviceName;  }   [StructLayout(LayoutKind.Sequential,CharSetCharSet=CharSet.Auto)]  publicstructRasStats  {  publicintdwSize;  publicintdwBytesXmited;  publicintdwBytesRcved;  publicintdwFramesXmited;  publicintdwFramesRcved;  publicintdwCrcErr;  publicintdwTimeoutErr;  publicintdwAlignmentErr;  publicintdwHardwareOverrunErr;  publicintdwFramingErr;  publicintdwBufferOverrunErr;  publicintdwCompressionRatioIn;  publicintdwCompressionRatioOut;  publicintdwBps;  publicintdwConnectionDuration;  }  [StructLayout(LayoutKind.Sequential,CharSetCharSet=CharSet.Auto)]  publicstructRasEntryName  {  publicintdwSize;  //[MarshalAs(UnmanagedType.ByValTStr,SizeConst=(int)RasFieldSizeConstants.  RAS_MaxEntryName+1)]  publicstringszEntryName;  //#ifWINVER5  //publicintdwFlags;  //[MarshalAs(UnmanagedType.ByValTStr,SizeConst=260+1)]  //publicstringszPhonebookPath;  //#endif  }  publicclassRAS  {  [DllImport("RaSAPa>i32.dll",  EntryPoint="RasEnumConnectionsA",  SetLastError=true)]   internalstaticexternintRasEnumConnections  (  refRASCONNlprasconn,//buffertoreceiveconnectionsdata  refintlpcb,//sizeinbytesofbuffer  refintlpcConnections//numberofconnectionswrittentobuffer  );    [DllImport("rasapi32.dll",CharSetCharSet=CharSet.Auto)]  internalstaticexternuintRasGetConnectionStatistics(  IntPtrhRasConn,//handletotheconnection  [In,Out]RasStatslpStatistics//buffertoreceivestatistics  );  [DllImport("rasapi32.dll",CharSetCharSet=CharSet.Auto)]  publicexternstaticuintRasHangUp(  IntPtrhrasconn//handletotheRASconnectiontohangup  );   [DllImport("rasapi32.dll",CharSetCharSet=CharSet.Auto)]  publicexternstaticuintRasEnumEntries(  stringreserved,//reserved,mustbeNULL  stringlpszPhonebook,//pointertofullpathand  //filenameofphone-bookfile  [In,Out]RasEntryName[]lprasentryname,//buffertoreceive  //phone-bookentries  refintlpcb,//sizeinbytesofbuffer  outintlpcEntries//numberofentrieswritten  //tobuffer  );   [DllImport("wininet.dll",CharSetCharSet=CharSet.Auto)]  publicexternstaticintInternetDial(  IntPtrhwnd,  [In]stringlpszConnectoid,  uintdwFlags,  refintlpdwConnection,  uintdwReserved  );   publicRAS()  {  }  }  publicenumDEL_CACHE_TYPE//要删除的类型。  {  File,//表示internet临时文件  Cookie//表示Cookie  };  publicclassRASDisplay  {  [DllImport("wininet.dll",CharSetCharSet=CharSet.Auto)]  publicstaticexternboolDeleteUrlCacheEntry(  DEL_CACHE_TYPEtype  );  privatestringm_duration;  privatestringm_ConnectionName;  privatestring[]m_ConnectionNames;  privatedoublem_TX;  privatedoublem_RX;  privateboolm_connected;  privateIntPtrm_ConnectedRasHandle;   RasStatsstatus=newRasStats();  publicRASDisplay()  {  m_connected=true;   RASlpras=newRAS();  RASCONNlprasConn=newRASCONN();   lprasConn.dwSize=Marshal.SizeOf(typeof(RASCONN));  lprasConn.hrasconn=IntPtr.Zero;   intlpcb=0;  intlpcConnections=0;  intnRet=0;  lpcb=Marshal.SizeOf(typeof(RASCONN));    nRet=RAS.RasEnumConnections(reflprasConn,reflpcb,ref  lpcConnections);  if(nRet!=0)  {  m_connected=false;  return;  }  if(lpcConnections>0)  {  //for(inti=0;i1)  {  names=newRasEntryName[lpNames];  for(inti=0;i0)  {  for(inti=0;i

关于C#中怎么实现ADSL自动拨号问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。


标题名称:C#中怎么实现ADSL自动拨号
文章URL:http://ybzwz.com/article/gsiehj.html