QProcess:可以調用外部進程
netsh wlan show interfaces:可以查看連接哪個wifi
netsh wlan show networks:顯示所有可用的wifi
netsh wlan delete profile name=”想要刪除的WiFi連接名稱”
netsh wlan show profile name="想要查看的WIFI密碼" key=clear
netsh 是通過 profile 文件來連接指定的 wifi,profile文件的創建只能通過圖像界面,所以無法用 netsh 連接未連接過的 wifi;同時無密碼的 wifi,默認是不自動生成 profile 文件,但可以手動設置生成。
cmd /c dir 是執行完dir命令后關閉命令窗口
QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput());
- QProcess p(0);
- p.start("cmd", QStringList()<<"/c"<<"ping www.baidu.com");
- p.waitForStarted();
- p.waitForFinished();
- QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput());
connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(start_read_output()));
QProcess process(this); process.start("cmd.exe"); process.write ("del E:\\a.txt\n\r"); process.write ("exit\n\r"); process.waitForFinished(); process.close();
記住一點,Netsh命令不僅讓你配置本地計算機,而且可以使你運用登錄腳本配置多台計算機。需要記住的另外一方面是,無線網絡配置文件是只讀的。這種文件是無法通過使用Netsh的WLAN命令進行修改的,但是,這種文件可以導入和導出。通過普通的Windows圖形用戶界面就可以創建和修改無線網絡的配置文件。