How to read MAC Address using PocketPC VB.NET application

G

Goran Djuranovic

Hi all,
How do I read MAC address of the Pocket PC using VB.NET application? I was
able to do the same thing in ASP.NET by passing the IP address and
translating it into MAC address. How is this done in VB.NET?
 
G

Guest

Using the the OpenNETCF smart device framework u can querry the network addapter for information such as the mac address:

Import OpenNETCF.Net

Friend Adapter As OpenNETCF.Net.Adapter
Dim b as Byte()
Adapter = OpenNETCF.Net.Networking.GetAdapters().Item(0)
b=Adapter.MacAddress
Dim i As Integer
Dim s As String = ""
For i = 0 To b.Length - 1
s = s + String.Format("{0:x2}", b(i))+ "."
Next
MessageBox.Show(s)

this should show you the devices mac address in an message box


Ali Gardezi
 
G

Guest

you can get the mac address using the OpenNETCF smartdevice framework:

Import OpenNETCF.Net

Dim Adapter As OpenNETCF.Net.Adapter
Adapter = OpenNETCF.Net.Networking.GetAdapters().Item(0)
Dim b As Byte() = Adapter.MacAddress
Dim i As Integer
Dim s As String = ""
For i = 0 To b.Length - 1
s = s + String.Format("{0:x2}", b(i)) + "."
Next
MessageBox.Show(s)


This will show you the devices mac address in a message box.

Ali Gardezi
 
G

Goran Djuranovic

Hi Ali,
My "OpenNETCF" library does not have "Net" on the list of its items, when I
hit the dot ("OpenNETCF.Net" not possible).

Any suggestions.

Thanks for your response.
Goran Djuranovic


Ali said:
Using the the OpenNETCF smart device framework u can querry the network
addapter for information such as the mac address:
 
G

Goran Djuranovic

Oouups, I found it. I guess I needed to add both references: "OpenNETCF" &
"OpenNETCF.Net"
My bad...

Goran Djuranovic

Ali said:
Using the the OpenNETCF smart device framework u can querry the network
addapter for information such as the mac address:
 
G

Goran Djuranovic

Hi Ali,
Here is the code I used (bit shorter):
----------------------------------------
Dim bc As BitConverter
MessageBox.Show(bc.ToString(OpenNETCF.Net.Networking.GetAdapters.Item(0).Mac
Address))
--------------------------------------------

BUT, both codes (yours and mine) work when the PDA is in the cradle. Here is
when it doesn't work: if the PDA is out of cradle, wireless is ON, and the
PDA has only one WiFi adapter, the application throws an
"ArgumentOutOfRange" exception. It looks like a bug in OpenNETCF SDE
framework 1.2 (the one I use).

I also tried some of the other suggestions to modify "OpenNETCF.Net"
library, but without success.
I am not sure how you got it to work, but here are couple of sites that
suggest there is bug in 1.2 framework:
http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=2530
http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=2138

Thanks for your time
Goran Djuranovic
 
G

Goran Djuranovic

The whole thing works fine in SDF 1.1, so I guess I will have to stick with
OpenNETCF SDF 1.1, until they fix the 1.2 bug.

Goran
 
P

Paul G. Tobey [eMVP]

This is the same bug just reported in another thread. I've fixed it and
posted the adjustments that you'd make to the source, if you are using it,
there. It's very simple (three lines)...

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top