2019,3 → 2019,71 |
|
} |
|
|
QList<TWmiMemoryModul> MainWindow::getWmiRAM(QString host, QString user_name, QString password) |
{ |
QList<TWmiMemoryModul> result; |
TWmiMemoryModul ramModul_tmp; |
bool ok; |
QString ansver_string; |
|
|
wmiThread.setHost(host); // çàäàåì õîñò |
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ |
wmiThread.setPassword( password); |
wmiThread.setWmiString(tr("SELECT BankLabel, Capacity, Manufacturer from Win32_PhysicalMemory")); |
wmiThread.start(QThread::NormalPriority); |
ok = wmiThread.wait(10000); |
|
if (ok){ |
QTextDocument * wmiDoc = ui->textEdit_2->document(); |
QTextCursor * wmiCursor; |
QStringList split_new_line; // |
QStringList fields_list; //â ýòîì ñïèñêå ñîõðàíèì ïîëÿ |
QStringList values_list; //à â ýòîì ñïèñêå - çíà÷åíèÿ |
wmiCursor = new QTextCursor(wmiDoc); |
ansver_string = wmiThread.resultString(); |
wmiCursor->insertText(ansver_string); |
split_new_line = ansver_string.split("\n", QString::SkipEmptyParts); // ðàçáèâàåíì îòâåò íà ñòðîêè |
if(split_new_line.count()>2) { |
QString tmp_str; |
tmp_str = split_new_line.at(1); |
fields_list = tmp_str.split("|"); |
|
for(int i=2; i< split_new_line.count(); i++) |
{ |
ramModul_tmp.bankLabel = ""; |
ramModul_tmp.capacity=0; |
tmp_str = split_new_line.at(i); |
values_list = tmp_str.split("|"); |
int index_tmp; |
index_tmp = fields_list.indexOf(tr("BankLabel")); // Â êàêîé ñëîò óñòàíîâëåí ìîäóëü ïàìÿòè |
if ((index_tmp!=-1) && (index_tmp < values_list.count())) ramModul_tmp.bankLabel = values_list.at(index_tmp); |
index_tmp = fields_list.indexOf(tr("Capacity")); // Ðàçìåð ïàìÿòè |
if ((index_tmp!=-1) && (index_tmp < values_list.count())) ramModul_tmp.capacity = QVariant(values_list.at(index_tmp)).asInt(); |
result << ramModul_tmp; |
|
|
|
|
}; |
|
return result; |
} |
else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò |
int m; |
m++; |
} |
else { |
wmiThread.stop(); |
ok = wmiThread.wait(10000); |
int k; |
k++; |
} |
|
|
|
return result; |
} |
|
|