471,325 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Get Mac address

Hi

I need to get a unique identifier to a machine, I chose to use a MAC
address. The problem I am having is that the methods I have found on
the internet and through Google groups aren't sufficient for what I
require.

Option 1 - using WMI
Unfortunately I'm using Framework 1.1
http://groups.google.co.uk/group/mic...3183a4dd?hl=en

Option 2 - Using Send ARP
The machine isn't always connected to a network so it doesn't always
have an IP address, no IP no ARP packets.

Any help would be much appreciated.

Feb 14 '06 #1
5 6688
Hi,
what is wrong with WMI ? it does work in 1.1 , use this code:

ManagementClass mc = new ManagementClass("Win32_NetworkAdapter");
foreach (ManagementObject mo in mc.GetInstances())
{
string macAddr = mo["MACAddress"] as string;
if ( macAddr != null && macAddr.Trim() != "" )
return macAddr.ToString();
}
Note that it does not work in win9X
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

<ad*****@awtxglobal.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi

I need to get a unique identifier to a machine, I chose to use a MAC
address. The problem I am having is that the methods I have found on
the internet and through Google groups aren't sufficient for what I
require.

Option 1 - using WMI
Unfortunately I'm using Framework 1.1
http://groups.google.co.uk/group/mic...3183a4dd?hl=en

Option 2 - Using Send ARP
The machine isn't always connected to a network so it doesn't always
have an IP address, no IP no ARP packets.

Any help would be much appreciated.

Feb 14 '06 #2
Windows Management Instrumentation ....

using System.Management;

...

ManagementClass mc = new ManagementClass("Win32_NetworkAdapter");

I had some trouble getting that code to work .....

error CS0234: The type or namespace name 'Management' does not exist in
the class or namespace 'System' (are you missing an assembly
reference?)

Feb 14 '06 #3
Hi,

<ad*****@awtxglobal.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Windows Management Instrumentation ....

using System.Management;

..

ManagementClass mc = new ManagementClass("Win32_NetworkAdapter");

I had some trouble getting that code to work .....

error CS0234: The type or namespace name 'Management' does not exist in
the class or namespace 'System' (are you missing an assembly
reference?)


You have to include a reference to System.Management in "Add reference"
form the project menu
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 14 '06 #4
I don't get what's the differenc between that and putting a using
statement in?

Feb 14 '06 #5
Do'h school boy error, I see what I've done now.

Thanks for your help Ignacio.

Feb 14 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by Alexander N. Spitzer | last post: by
8 posts views Thread by YAN | last post: by
4 posts views Thread by andreas.w.h.k. :-\) | last post: by
6 posts views Thread by Nicolas Noakes | last post: by
36 posts views Thread by Julienne Walker | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.