|
-
Apr 7th, 2006, 10:24 PM
#1
Re: [2005] MAC Address -> IP Address
 Originally Posted by kasracer
gigemboy, you can have multiple network adapters on 1 computer which is probably why the IP addresses are an array.
Yeah but it loops for all network interfaces. Each network interface has the property that is an array. You wont have 2 IP's for 1 network interface... as far as I know... unless maybe 1 will return the regular IP and loopback IP?
-
Apr 8th, 2006, 12:23 AM
#2
Re: [2005] MAC Address -> IP Address
 Originally Posted by gigemboy
Yeah but it loops for all network interfaces. Each network interface has the property that is an array. You wont have 2 IP's for 1 network interface... as far as I know... unless maybe 1 will return the regular IP and loopback IP?
The loopback address is implimented in the device's drivers. It shouldn't count that as a second IP.
It's probably related to network cards like this one: http://www.newegg.com/Product/Produc...82E16833106217
-
Apr 9th, 2006, 12:26 PM
#3
Re: [2005] MAC Address -> IP Address
you don't really need to add references to the ManagementObject, you could always use a simple API call ( *** just as an alternative *** )
on your local network you can use the SendARP API, you can also use this for any network interfaces on your own machine.
here's a quick example i bunged together for you , it's based on a few C# examples floating about, i just modified it to work in VB.NET...
VB Code:
[COLOR=Blue]Private Declare[/COLOR] [COLOR=Blue]Function[/COLOR] inet_addr [COLOR=Blue]Lib[/COLOR] "ws2_32.dll" ([COLOR=Blue]ByVal[/COLOR] cp [COLOR=Blue]As String[/COLOR]) [COLOR=Blue]As[/COLOR] Int32
[COLOR=Blue]Private Declare Function[/COLOR] SendARP [COLOR=Blue]Lib[/COLOR] "IPHLPAPI.dll" ([COLOR=Blue]ByVal[/COLOR] DestIP [COLOR=Blue]As Integer[/COLOR], [COLOR=Blue]ByVal[/COLOR] SrcIP [COLOR=Blue]As[/COLOR] Int32, [COLOR=Blue]ByVal[/COLOR] pMacAddr [COLOR=Blue]As Byte[/COLOR](), [COLOR=Blue]ByRef [/COLOR] PhyAddrLen [COLOR=Blue]As[/COLOR] Int32) [COLOR=Blue]As[/COLOR] Int32
[COLOR=Blue]Private Sub[/COLOR] Button1_Click([COLOR=Blue]ByVal[/COLOR] sender [COLOR=Blue]As[/COLOR] System.Object, [COLOR=Blue]ByVal[/COLOR] e [COLOR=Blue]As[/COLOR] System.EventArgs) [COLOR=Blue]Handles[/COLOR] Button1.Click
[COLOR=Green]'/// buffer to receive the MacAddress into...[/COLOR]
[COLOR=Blue]Dim[/COLOR] buf(6) [COLOR=Blue]As Byte[/COLOR]
[COLOR=Green]'/// specify your ip to check here *** remember to add Imports System.NET at the top of the code window *** ...[/COLOR]
[COLOR=Blue]Dim[/COLOR] ip [COLOR=Blue]As[/COLOR] IPAddress = IPAddress.Parse("192.168.0.4")
[COLOR=Blue]If[/COLOR] SendARP(BitConverter.ToInt32(IPAddress.Parse("192.168.0.4").GetAddressBytes, 0), 0, buf, 6) = 0 [COLOR=Blue]Then[/COLOR]
Console.WriteLine(BitConverter.ToString(buf, 0, 6))
[COLOR=Blue]End If[/COLOR]
[COLOR=Blue]End Sub[/COLOR]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|