/*查看本机WiFi密码时间:5月7日11:24:26 */ #include <iostream>#include <string>#include <cstdlib>#include <cstdio>using namespace std;class Wifi{private:string name;public:Wifi(string _name):name(_name){}string getName(){return this->name; }};void showWifiPassword(Wifi wifi){string cmd="netsh wlan show profiles "+wifi.getName()+" key=clear >>1.tmp";system(cmd.c_str());FILE *fp;if((fp=fopen("1.tmp","r"))==NULL){cout<<"file open error"<<endl;}char lineTxt[1024];for(int i=0;i<33;i++){fgets(lineTxt,1024,fp);}string passwd=lineTxt;int c=passwd.find(':');passwd.erase(passwd.begin(),passwd.begin()+c+2);cout<<"Wifi Name:"<<wifi.getName()<<endl;cout<<"Wifi Password: "<<passwd; system("pause");}int main(int argc,char *argv[]){if(argc<2){cout<<"error"<<endl;}Wifi w(argv[1]);showWifiPassword(w);return 0;} /*TP-LINK_E467*/
使用方式,编译完成之后,添加参数例如
我将上面代码编译show.exe
运行 showTP-LINK_E467
得到如下结果
如果觉得《C++ 查看本机WiFi密码》对你有帮助,请点赞、收藏,并留下你的观点哦!