#include#include#includeclass NetInfo : public QThread
{Q_OBJECT
public:
explicit NetInfo(QObject* parent = nullptr);
protected:
void run();
signals:
void sendCurrentNetInfo(const QString netInfo);
};
NetInfo::NetInfo(QObject* parent)
: QThread(parent)
{}
void NetInfo::run()
{PMIB_IFTABLE pTable = nullptr;
DWORD dword = 0;
ULONG retCode = GetIfTable(pTable, &dword, true);
if(retCode == ERROR_NOT_SUPPORTED)
return;
if(retCode == ERROR_INSUFFICIENT_BUFFER)
pTable = (PMIB_IFTABLE)new BYTE[65535];
//上傳速度
DWORD dwIn = 0;
//下載速度
DWORD dwOut = 0;
//上傳最后字節(jié)
DWORD dwLastIn = 0;
//下載最后字節(jié)
DWORD dwLastOut = 0;
while(true)
{GetIfTable(pTable, &dword, true);
DWORD dwInOc = 0;
DWORD dwOutOc = 0;
for(UINT i = 0; i< pTable->dwNumEntries; i++)
{MIB_IFROW row = pTable->table[i];
dwInOc += row.dwInOctets;
dwOutOc += row.dwOutOctets;
}
dwIn = dwInOc - dwLastIn;
dwOut = dwOutOc - dwLastOut;
if(dwLastIn<= 0)
dwIn = 0;
else
dwIn = dwIn / 1024;
if(dwLastOut<= 0)
dwOut = 0;
else
dwOut = dwOut / 1024;
dwLastIn = dwInOc;
dwLastOut = dwOutOc;
emit sendCurrentNetInfo(QString("%1kb/s").arg(dwIn));
QThread::msleep(1000);
}
delete [] pTable;
}
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧
站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到巴彥淖爾網(wǎng)站設(shè)計(jì)與巴彥淖爾網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊(cè)、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋巴彥淖爾地區(qū)。
分享文章:Qt/C++獲取當(dāng)前網(wǎng)絡(luò)網(wǎng)速-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://jinyejixie.com/article36/ghgpg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、網(wǎng)站導(dǎo)航、品牌網(wǎng)站建設(shè)、商城網(wǎng)站、網(wǎng)站營(yíng)銷、App開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容