[SOLVED] list of all computers in local network (windows)
-
wrote on 2 May 2014, 09:22 last edited by
hello,
im trying o get a list of all computers in local network. I´m on windows. I can
t find a way to do that.
Any idears?
Thanks in advance! -
wrote on 2 May 2014, 09:30 last edited by
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. -
wrote on 2 May 2014, 09:43 last edited by
Hello,
Thanks for your reply!
I already tried that already and yes, it works. B U T :
it is very very slow. i have to wait several minutes until it´s finished.
it there a faster alternative? -
wrote on 2 May 2014, 10:04 last edited by
Why you don't use the ipscan approach?
You have to scan each ip of your subnet and, for each ip, look if there are ports open. -
wrote on 2 May 2014, 10:40 last edited by
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();
} -
wrote on 2 May 2014, 10:47 last edited by
Please, search for ipscan.exe and look at how this program works.
You have to use threads to scan fast and simultaneous. -
wrote on 2 May 2014, 11:28 last edited by
ok, thanks.
I`ll search for this! -
wrote on 2 May 2014, 12:02 last edited by
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.
-
wrote on 2 May 2014, 13:14 last edited by
Great! This might be the solution! Thanks!
-
wrote on 5 May 2014, 08:27 last edited by
Hi,
Please place [SOLVED] before your first post. Keeps us from reading unneeded and others for finding a solution to there problem.
7/10