IP设置应用v1.0

  刚学MFC,到现在都没有一本像样的书,图书馆里的早就让人借光了,剩下的书可想而知,根本没法看,还不如看电子版的。

  很傻的方法~~ 自己可以用MFC生成一个简单的对话框就可以实现基本功能了

#include <iostream>
#include <string>
#include <cstdlib>
#include <windows.h>


using namespace std;

//设置命令行

string cmd="netsh interface ip set address name=\"本地连接\" static ";

int main()
{
    string IPAddress="***.***.***.***";                  //ip地址
    string Mask="255.255.255.0";                        //子网掩码
    string DefaultGateway="***.***.***.254";            //默认网关
    cmd+=IPAddress+" "+Mask+" "+DefaultGateway;
    cout<<cmd<<endl;

    HWND hwnd=GetForegroundWindow();
    ShowWindow(hwnd,SW_HIDE);

    system("@echo off");
    system(cmd.c_str());
    system("@echo on");
    system("ipconfig /all");
    return 0;
}
原文地址:https://www.cnblogs.com/coder2012/p/2766969.html