示例#1
0
        /// <summary>
        /// 拨号
        /// </summary>
        /// <param name="strEntryName">条目名称</param>
        /// <param name="strError">错误</param>
        /// <returns>结果</returns>
        public bool DialUp(string strEntryName, out string strError)
        {
            bool          lpfPassword = false;
            RASDIALPARAMS structure   = new RASDIALPARAMS();

            structure.dwSize      = Marshal.SizeOf(structure);
            structure.szEntryName = strEntryName;
            RasDialEvent lpvNotifier = new RasDialEvent(this.RasDialFunc);
            int          nErrorValue = RasGetEntryDialParams(null, ref structure, ref lpfPassword);

            if (nErrorValue != 0)
            {
                strError = this.GetErrorString(nErrorValue);
                return(false);
            }
            this.ConnectNotify("正在连接" + structure.szEntryName + "...", 1);
            this.EntryName = strEntryName;
            this.hrasconn  = 0;
            nErrorValue    = RasDial(0, null, ref structure, 0, lpvNotifier, ref this.hrasconn);
            if (nErrorValue != 0)
            {
                strError = this.GetErrorString(nErrorValue);
                this.ConnectNotify(strError, 3);
                return(false);
            }
            this.ConnectNotify("正在打开端口...", 1);
            strError = null;
            return(true);
        }
示例#2
0
 private static extern int RasDial(int lpRasDialExtensions, string lpszPhonebook, ref RASDIALPARAMS lpRasDialParams, int dwNotifierType, RasDialEvent lpvNotifier, ref int lphRasConn);
示例#3
0
 /// <summary>
 /// 拨号
 /// </summary>
 /// <param name="strEntryName">条目名称</param>
 /// <param name="strError">错误</param>
 /// <returns>结果</returns>
 public bool DialUp(string strEntryName, out string strError)
 {
     bool lpfPassword = false;
     RASDIALPARAMS structure = new RASDIALPARAMS();
     structure.dwSize = Marshal.SizeOf(structure);
     structure.szEntryName = strEntryName;
     RasDialEvent lpvNotifier = new RasDialEvent(this.RasDialFunc);
     int nErrorValue = RasGetEntryDialParams(null, ref structure, ref lpfPassword);
     if (nErrorValue != 0)
     {
         strError = this.GetErrorString(nErrorValue);
         return false;
     }
     this.ConnectNotify("正在连接" + structure.szEntryName + "...", 1);
     this.EntryName = strEntryName;
     this.hrasconn = 0;
     nErrorValue = RasDial(0, null, ref structure, 0, lpvNotifier, ref this.hrasconn);
     if (nErrorValue != 0)
     {
         strError = this.GetErrorString(nErrorValue);
         this.ConnectNotify(strError, 3);
         return false;
     }
     this.ConnectNotify("正在打开端口...", 1);
     strError = null;
     return true;
 }
示例#4
0
 private static extern int RasDial(int lpRasDialExtensions, string lpszPhonebook, ref RASDIALPARAMS lpRasDialParams, int dwNotifierType, RasDialEvent lpvNotifier, ref int lphRasConn);