I trying to run “net use \server_ip” and parse result. Platform – Windows
I have the following code:
QProcess *prc = new QProcess(0);
QString exec="net use";
QStringList params;
params << "\\\\" + getServerIP();
prc->start(exec,params);
qDebug() << "exec process";
prc->waitForFinished();
qDebug() << prc->readAll() << prc->exitStatus();;
delete connected;
But readAll() reurns “” and exitStatus() returns 0.
Do you guys have any suggestion?
My suggestion would be to delete all of the above, and call WNetAddConnection1 instead.
At least if I’m interpreting what you have above correctly, it seems to be a really roundabout version of something like this:
If GetServerIP returns a QString, you may need to add a call to
toAscii(or toLatin1, toLocal8Bit, etc.) to convert it to get something `WNetAddConnection knows how to deal with.WNetAddConnection2orWNetAddConnection3. Microsoft officially recommends the latter, but you don’t seem to need any of the extra capabilities they provide.