zoukankan      html  css  js  c++  java
  • 用C#实现宽带重新拨号

     

    我们做一些软件的时候常常要用到换IP的操作,其实简单的换IP的方法就是重新拨号啊,下面就是我实践成功的重新拨号的代码,很简单的,是一个单独的类。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;//诊断,调用进程

    namespace QQ号批量注册
    {
    class ADSLHelper
    {

    public void Connect(string connectionName, string user, string pass)
    {
    string arg = string.Format("rasdial \"{0}\" {1} {2}", connectionName, user, pass);
    InvokeCmd(arg);
    }
    public void Disconnect(string connectionName)
    {
    string arg = string.Format("rasdial \"{0}\" /disconnect", connectionName);
    InvokeCmd(arg);
    }
    public static string InvokeCmd(string cmdArgs)
    {
    Process p = new Process();
    p.StartInfo.FileName = "cmd.exe";
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardInput = true;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.RedirectStandardError = true;
    p.StartInfo.CreateNoWindow = true;
    p.Start();
    p.StandardInput.WriteLine(cmdArgs);
    p.StandardInput.WriteLine("exit");
    return p.StandardOutput.ReadToEnd();
    }

    }
    }

  • 相关阅读:
    ConcurrentHashMap get方法保持同步的解释
    HashMap resize导致死循环
    ConcurrentHashMap原理详解
    单列索引和联合索引区别
    优先队列
    大根堆排序
    小根堆排序
    基础哈夫曼树-最简单的
    二叉查找树
    二叉查找树
  • 原文地址:https://www.cnblogs.com/minotmin/p/MinotMin.html
Copyright © 2011-2022 走看看