[SOLVED] list of all computers in local network (windows)
-
Hi,
I'm guessing that you use TCP/IP v4 network as LAN?
Then this might be something for you:Docs: If you pass a literal IP address to name instead of a host name, QHostInfo will search for the domain name for the IP (i.e., QHostInfo will perform a reverse lookup). On success, the resulting QHostInfo will contain both the resolved domain name and IP addresses for the host name. Example:
@QHostInfo::lookupHost("4.2.2.1",
this, SLOT(lookedUp(QHostInfo)));@
Simply loop around every possible IP adres within your LAN and you're done. -
Here some code:
I search for every adress in my network.
do you that mean with ipscan?It works, but very very slow.
it takes minutes!QString network = "130.17.40.";
for(int i=0;i<255;i++) { QString currIp = (network+"%1").arg(i); qDebug() << "CURR IP: " << currIp;
// QHostInfo::lookupHost(currIp,
// this, SLOT(lookedUp(QHostInfo)));
QHostInfo HI = QHostInfo::fromName(currIp);
qDebug() << "NAME: "<< HI.hostName();
} -
You might need the QtConcurrent class to handle multiple short threads and add signals if an used IP was found. Then you're able to fast scan all IP's in your LAN.
-
Hi,
Please place [SOLVED] before your first post. Keeps us from reading unneeded and others for finding a solution to there problem.