Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAC address in Compact Framework

How can I get the MAC Address using only the compact framework?

like image 373
jalcom Avatar asked Apr 25 '26 08:04

jalcom


1 Answers

1.4 of the OpenNETCF code gets the information from the following P/Invoke call:

    [DllImport ("iphlpapi.dll", SetLastError=true)]
    public static extern int GetAdaptersInfo( byte[] ip, ref int size );

The physical address (returned as MAC address) I think is around about index 400 - 408 of the byte array after the call. So you can just use that directly if you don't want to use OpenNETCF (why though? OpenNETCF rocks more than stone henge!)

Wonderful P/Invoke.net gives a full example here.

Oh and to properly answer your question:

only using the Compact Framework

You cant. That's life with CF, if you want some fun try sending data with a socket synchronously with a timeout. :D

like image 100
Quibblesome Avatar answered May 02 '26 12:05

Quibblesome



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!