I am working on developing a simple Wake on Lan program of my own and a feature I have seen and liked in a couple programs I downloaded before deciding to write my own is the ability to find another computer's MAC address if it is turned on and connected to the network.
One method I have found is if you go to cmd.exe and type out:
ping <computer-name>
arp -a
It will display the pinged comptuers MAC address in a table.
Instead of running the CMD and trying to then parse some text I wanted a way to do this all from inside my program.
I found a windows API that is supposed to give me access to the ARP table, getIpNetTable and even found the function declaration for it:
when I try to call on the above function with the code:
I get the following error:
Searching the windows MSDN showed me that they know the API exists but was not very helpful to me in figuring out how to actually write a program that uses it...
Here are some links that I have already found:
MSDN for getIpNetTable:
http://msdn2.microsoft.com/en-us/library/aa365956.aspx
A VB 6.0 program that uses getIpNetTable (I tried to translate it into vb 2005 on my own and failed):
http://www.ex-designz.net/apidetail.asp?api_id=443
Thanks for your time and I hope to hear back from you.
One method I have found is if you go to cmd.exe and type out:
ping <computer-name>
arp -a
It will display the pinged comptuers MAC address in a table.
Instead of running the CMD and trying to then parse some text I wanted a way to do this all from inside my program.
I found a windows API that is supposed to give me access to the ARP table, getIpNetTable and even found the function declaration for it:
VB.NET:
Private Declare Function GetIpNetTable Lib "Iphlpapi.dll" (pIpNetTable As Byte, pdwSize As Long, ByVal bOrder As Long) As Long
when I try to call on the above function with the code:
VB.NET:
Dim Ret As Long
Dim test As Byte = 0&
GetIpNetTable(test, Ret, True)
I get the following error:
The problem arises in the fact that for the life of me I can not figure out how to use this function. I have found several example programs but they are all written in either VB 6.0 or VC 6.0 neither of which I have enough experience to translate to VB 2005.PInvokeStackImbalance was detected
Message: A call to PInvoke function 'CafUtilsDev!CafUtilsDev.Form1::GetIpNetTable' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Searching the windows MSDN showed me that they know the API exists but was not very helpful to me in figuring out how to actually write a program that uses it...
Here are some links that I have already found:
MSDN for getIpNetTable:
http://msdn2.microsoft.com/en-us/library/aa365956.aspx
A VB 6.0 program that uses getIpNetTable (I tried to translate it into vb 2005 on my own and failed):
http://www.ex-designz.net/apidetail.asp?api_id=443
Thanks for your time and I hope to hear back from you.