Exemplo n.º 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);
        }
Exemplo n.º 2
0
 private static extern int RasDial(int lpRasDialExtensions, string lpszPhonebook, ref RASDIALPARAMS lpRasDialParams, int dwNotifierType, RasDialEvent lpvNotifier, ref int lphRasConn);
Exemplo n.º 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;
 }
Exemplo n.º 4
0
 private static extern int RasDial(int lpRasDialExtensions, string lpszPhonebook, ref RASDIALPARAMS lpRasDialParams, int dwNotifierType, RasDialEvent lpvNotifier, ref int lphRasConn);