Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] Get hostname & MAC address from IP Adreess
In my application I want to get hostname & MAC address from IP address (in my LAN).
I used these code for find hostname, but nothing appeared in lineedit.
Thanks a lot.
Hi, you need also to lookup 192.168.1.1. for example:
HI = QHostInfo::fromName("192.168.1.1");
Hi dear hskoglund & thanks for your response,
I added the code you mentioned but lineedit shows the ip address again! (Not hostname)!
I tested by "192.168.1.1" & a valid ip address but unfortunately did not work.
Special thanks to dear hskoglund!
You are right.
I tested another IP addresses & worked!
Any idea about MAC address?
For your own computer to get the MAC addresses, you can use "QNetworkInterface::hardwareAddress":http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkinterface.html#hardwareAddress
For other computers on the same LAN, you need to use the ARP protocol. You can test, opening a CMD window, first ping the computer you want the MAC address of, then type
(Physical address in the list is the MAC address)
Thanks for your response dear hskoglund.
Is not there any function in Qt to get IP address & give MAC Address?
No for other computers on the same LAN I don't think so :-(
But if you write one such function using the ARP protocol you could contribute it to Qt.
Thank you very much, dear hskoglund.
ll search & if I find anyting, Ill put them here Insha'Allah.
Problem Marked as Solved!