I am working on getting MAC address of a newly connected client using C#.
I have written server application and when client connects to my server, I want to get MAC addresses of clients and store it in database.
I could get IP address of client but could not find a way to get MAC address
Can anyone please help me?

Other thing that I am trying to do is shrink an image sent by a server to client. When an image is sent by server (picturebox in server is larger than that at client), client can not display it completely in its picturebox. I can see half image.
Is there any way I can shrink image sent by server?


8 Years
Discussion Span
Last Post by JamesCherrill

Refer these links.

PhysicalAddress Class
Get MAC address of client machine using C#

Also try this code snippet.

using System;
using System.Windows.Forms;
using System.Management; 

 private void button1_Click(object sender, EventArgs e)
            ManagementObjectSearcher objQuery = null;
            ManagementObjectCollection queryCollection = null;

                objQuery = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");

                queryCollection = objQuery.Get();

                foreach (ManagementObject mgmtObject in queryCollection)
                    if (mgmtObject["MacAddress"] != null)
            catch (Exception ex)


Are you running your software on both ends of the connection? MAC addresses are only "guaranteed valid" for layer 2 communications in a LAN. They do not traverse a router as you would think.

That being said if it is your software running on both ends then you can use the code Ramesh provided. If you just have an open socket then you can't reliably determine the remote MAC.


Thanks Ramesh.
I could use it to find a MAC address of local machine when local machine is a laptop or desktop.

But when I tried to do the same on PDA, I found that it does not have system.net.management and system.net.networkinterface namespace

Do you have any idea about how to get MAC addresses on PDA?



Got MAC address of PDA.
But now i get 2 mac addresses, both belong to same networktype "Ethernet".
If I see system configuration of WM, then I see one of the above physical addresses.
Which one does windows mobile use to send packets on network?
(one that is listed in system configuration or other physical address which is returned by opennetcf library functions?)

Thanks all.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.