AnsiString str="interface ip add address \"本地连接\" static 192.1.2.44      255.255.255.0  1";
ShellExecute(Application ->Handle ,"open","netsh",str.c_str(),NULL,SW_HIDE);
以上代码放在一个按钮的click 里面 ShellExecute ()返回值是42,也就是函数执行成功,可是ip没有增加啊 求指导。

解决方案 »

  1.   

    AnsiString str="interface ip add address \"本地连接\" static 192.1.2.44      255.255.255.0";
    后面那个1不要,那是添加网关才用的.
      

  2.   

    楼主先在命令行里执行你的命令,如果成功生效后调用ShellExecute执行.
      

  3.   

    支持,另外命令行的命令,建议用WinExec来执行.
    ------------------------------------------------------------------------sign

      

  4.   

    执行DOS命令最好用system()函数。
    int system(
       const char *command //Command to be executed.
    );