I'm in trouble finding a suitable solution to my problem, and I hope you can help me with.
I wanna scan the local network in a Windows 7 environnement, and I must return:
- IP
- MAC address
- hostname
Of all PC in the local network. I was looking on the net, but i can't seem to found something who will do the three of that.
If someone knew a function or a group of function who can do the trick, it will be much appreciated.
I must do this in C++ or C#, but if possible, i'd rather prefer C++, since I'm better at it.
Thanks in advance for your support.
相关问题
- Sorting 3 numbers without branching [closed]
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- How to compile C++ code in GDB?
I made a really basic prototype for you in c++ to get you onto the right path.
But keep in mind that its not safe at all and it can horribly fail at any second, you'll have to make some more checks to make sure the hostname doesn't overflow etc. And you'll also have to figure out how you want to fill the
char address[][32]
array because this is just handing in four example IPs.main.h:
main.cpp:
Output:
You'll want to link
iphlpapi.lib
andws2_32.lib
, I'm using GCC sopragma comment(lib, "")
wont work, but if you're using msvc you can uncomment the lines in the header.