获取windows内备份的wifi

获取电脑内备份的wifi

#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;

void outwlan(string wlan)
{
    bool flag=0;
    string cmd="netsh wlan show profile name = ";
    cmd+=wlan;
    cmd+=" key = clear > .\\temp.txt";
    system(cmd.c_str());
    ifstream infile;
    infile.open(".\\temp.txt");
    string buff;
    while(getline(infile,buff))
    {
        stringstream is(buff);
        string keyWord;
        is>>keyWord;
        if(keyWord=="名称")
        {
            is>>keyWord>>keyWord;
            cout<<setw(20)<<keyWord<<":     ";
        }
        if(keyWord=="关键内容")
        {
            flag=1;
            is>>keyWord>>keyWord;
            cout<<keyWord<<endl;
            break;
        }
    }
    infile.close();
    if(!flag)cout<<endl;
    system("del .\\temp.txt");
}

int main()
{
    system("netsh wlan show profiles > .\\wlan.txt");
    ifstream infile;
    infile.open(".\\wlan.txt");
    string temp;
    while(getline(infile,temp))
    {
        stringstream is(temp);
        string wlan;
        is>>wlan;
        if(wlan=="所有用户配置文件")
        {
            is>>wlan>>wlan;
            outwlan(wlan);
        }
    }
    infile.close();
    system("del .\\wlan.txt");
    system("pause");
    return 0;
}

文章目录