public int CreatConnect(string name, string number, string modem, string user, string password) { byte[] bytes = Encoding.Default.GetBytes(modem); byte[] numArray = Encoding.Default.GetBytes(name); byte[] bytes1 = Encoding.Default.GetBytes(number); byte[] numArray1 = Encoding.Default.GetBytes(user); byte[] bytes2 = Encoding.Default.GetBytes(password); return(PigTao.RasCreateEntry(numArray, bytes1, bytes, numArray1, bytes2)); }
public string[] EnumConnect() { byte[] numArray = new byte[0x2800]; PigTao.MRasEnumDev(numArray); string str = Encoding.Default.GetString(numArray); char[] chrArray = new char[1]; chrArray[0] = '*'; return(str.Split(chrArray)); }
private void DialForm_Load(object sender, EventArgs e) { PigTao pigTao = new PigTao(); string[] strArrays = pigTao.EnumConnect(); for (int i = 0; i < strArrays.GetLength(0) - 1; i++) { this.comboBox1.Items.Add(strArrays[i]); } if (this.comboBox1.Items.Count == 0) { MessageBox.Show("没有任何连接"); base.Close(); return; } else { this.comboBox1.SelectedIndex = 0; return; } }
private void BW_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker backgroundWorker = sender as BackgroundWorker; bool argument = (bool)e.Argument; string str = string.Concat(Directory.GetCurrentDirectory(), "\\MDMSaro.inf"); InstallMainClass installMainClass = new InstallMainClass(); backgroundWorker.ReportProgress(1, string.Concat(">>INF PATH ", str, "\r\n")); InstallMainClass.bw = backgroundWorker; if (!argument) { if (installMainClass.install(str, "SaroCDMA", 0, SetupForm.sfm.comboBox1.SelectedItem.ToString(), "", "115200")) { backgroundWorker.ReportProgress(2, ">>安装成功!!!\r\n"); backgroundWorker.ReportProgress(1, ">>正在创建新连接!!!\r\n"); PigTao pigTao = new PigTao(); int num = pigTao.CreatConnect("SaroCDMA", "#777", "桑荣 6200 CDMA modem", "CARD", "CARD"); if (num == 0 || num == 183) { backgroundWorker.ReportProgress(2, ">>创建新连接成功,拨号名SaroCDMA!!!\r\n"); backgroundWorker.ReportProgress(1, ">>正在设置SaroCDMA为默认连接\r\n"); SetDefaultConnection setDefaultConnection = new SetDefaultConnection(); setDefaultConnection.Set("SaroCDMA"); backgroundWorker.ReportProgress(2, ">>设置成功!\r\n"); PBK pBK = new PBK(); pBK.DO("[SaroCDMA]"); backgroundWorker.ReportProgress(2, ">>所有任务安装设置成功!!!"); return; } else { backgroundWorker.ReportProgress(3, string.Concat(">>创建新连接失败,出错信息:", num.ToString())); backgroundWorker.ReportProgress(3, ">>安装中止!!!"); return; } } else { backgroundWorker.ReportProgress(3, ">>安装失败!!!"); return; } } else { if (installMainClass.install(str, "SaroGPRS", 0, SetupForm.sfm.comboBox1.SelectedItem.ToString(), "at+cgdcont=1,\"ip\",\"cmnet\"", "57600")) { backgroundWorker.ReportProgress(2, ">>安装成功!!!\r\n"); backgroundWorker.ReportProgress(1, ">>正在创建新连接!!!\r\n"); PigTao pigTao1 = new PigTao(); int num1 = pigTao1.CreatConnect("SaroGPRS", "*99***1#", "桑荣 3100 GPRS modem", "", ""); if (num1 == 0 || num1 == 183) { backgroundWorker.ReportProgress(2, ">>创建新连接成功,拨号名SaroGPRS!!!\r\n"); backgroundWorker.ReportProgress(1, ">>正在设置SaroGPRS为默认连接\r\n"); SetDefaultConnection setDefaultConnection1 = new SetDefaultConnection(); setDefaultConnection1.Set("SaroGPRS"); backgroundWorker.ReportProgress(2, ">>设置成功!\r\n"); PBK pBK1 = new PBK(); pBK1.DO("[SaroGPRS]"); backgroundWorker.ReportProgress(2, ">>所有任务安装设置成功!!!"); return; } else { backgroundWorker.ReportProgress(3, string.Concat(">>创建新连接失败,出错信息:", num1.ToString())); backgroundWorker.ReportProgress(3, ">>安装中止!!!"); return; } } else { backgroundWorker.ReportProgress(3, ">>安装失败!!!"); return; } } }