Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Problem in Getting MAC Address of a Remote machine...

Problem in Getting MAC Address of a Remote machine...

Scheduled Pinned Locked Moved C#
csharpsysadminhelpc++question
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Balagurunathan S
    wrote on last edited by
    #1

    Hi Friends.. I nee to get Mac address of a Remote machine for which i am using VC++ dll method("iphlpapi.dll") to do so..I am using the followin C# code to get the MAC Address.. public class clsMacAdd { [DllImport("iphlpapi.dll", ExactSpelling=true)] public static extern int SendARP( int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen ); public static string GetMacaddress(string strHostName) { System.Net.IPHostEntry Tempaddr = null; string[] Ipaddr = new string[3]; //strHostName = Request.UserHostName; if ( strHostName == "127.0.0.1" ) { strHostName = "system102"; } Tempaddr = (System.Net.IPHostEntry)Dns.GetHostByName( strHostName ); System.Net.IPAddress[] TempAd = Tempaddr.AddressList; foreach(IPAddress TempA in TempAd) { Ipaddr[1] = TempA.ToString(); byte[] ab = new byte[6]; int len = ab.Length; // This Function Used to Get The Physical Address //int r = SendARP(int(TempA.Address), 0, ab, ref len ); int r = SendARP( (int) TempA.Address, 0, ab, ref len ); string mac = BitConverter.ToString( ab, 0, 6 ); return mac; } return null; } } } I am getting the MAC address when i run in enterprise network(local),but when i host it a web server(live) i couldn't get the MAC Address..Wat could be the problem..? Someone help in this regard as early as possible.. Regards,

    Balaguru

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups