473,503 Members | 4,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get network card's MAC address?

Anyone have seem a sample code or some white papers for this?

Thanks in advance.

--

---------------
Valmir Cinquini

Nov 15 '05 #1
3 4544
"Bill McNeal" <Bi********@Bol.com.br> wrote in news:#ASu9Q#mDHA.3732
@tk2msftngp13.phx.gbl:
Anyone have seem a sample code or some white papers for this?

Thanks in advance.


You can do this with WMI.

Add the System.Management namespace to your code and then use
ManagementClass("Win32_NetworkAdapter") with the GetInstances Method to get
all Instances of Networkcards on your system.

When you identified the right instance you can use the properties
collection to retrieve values like MAC Address.

--
best regards

Peter Koen
-----------------------------------
MCAD, CAI/R, CAI/S, CASE/RS, CAT/RS
http://www.kema.at
Nov 15 '05 #2
Try this:

using System;
using System.Management;
public class Wmis {
public static void Main() {
using (ManagementObject netw = new ManagementObject("Win32_NetworkAdapterConfiguratio n.Index=1"))
{
string s = netw["MACAddress"].ToString();
Console.WriteLine( "MAC Address\t‘{0}’", s);
}
}
}
//Index = 1 is the adaptors configuration

Willy.
"Bill McNeal" <Bi********@Bol.com.br> wrote in message news:%2******************@tk2msftngp13.phx.gbl...
Anyone have seem a sample code or some white papers for this?

Thanks in advance.

--

---------------
Valmir Cinquini

Nov 15 '05 #3
Ok, thank you all for the samples.

--

---------------
Valmir Cinquini

Cidadania Italiana: visite http://www.cinquini.com.br
Banda larga de 1º mundo: Visite http://speedy.bravehost.com/speedy.htm
Lista MS-SQL: http://br.groups.yahoo.com/group/mssql-pt/join
Lista C#: http://br.groups.yahoo.com/group/csharp-pt/join
"Bill McNeal" <Bi********@Bol.com.br> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Anyone have seem a sample code or some white papers for this?

Thanks in advance.

--

---------------
Valmir Cinquini

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2273
by: Baihao Yuan | last post by:
Hello, I have a machine, which has two network cards, network card 1 and network card 2, they are on different subnetworks. The IP address of network card 1 is 192.0.0.1, the IP address of...
0
4539
by: John Lucas | last post by:
I have been reading many of the posts about determining which network card to use (in a machine with multiple nics), and determining whether or not that card is active. I'm hoping this will help...
0
2816
by: Alphamacaroon | last post by:
All, I'm wondering if anyone can help me with a strange problem I'm having. First off, here's what I'm trying to do: I'm developing a UDP network application that should allow the end user to...
2
9388
by: Marc-André | last post by:
Hi, I would to know if there's a way to use a particular network interfaces to access network(programmatically c#). The problem is that if my wireless network card is working, I want my...
3
6037
by: Mark Prenter | last post by:
Hello, I'm trying to find a way to retrieve the MAC address from a network card in a Visual C++ .NET managed application. I've found some examples in C#, but I just can't get them to work in C++....
5
11134
by: Paul Bromley | last post by:
How do I know which IP address is active?? I have created the following class and this works well, but the first address it obtains on my machine is not the active one - in fact I do not know...
1
1613
by: Rollasoc | last post by:
Hello, I have a situation with my PC, where I have three network cards installed. I have a piece of hardware sending UDP messages every now and then. I want to capture these messages. But I...
2
1932
by: Salad | last post by:
If I work on my app on my standalone, things are always fast. If I have an non-split app on the network it runs fast. If I split the app and have both the front end and backend on the network...
3
3528
by: tag | last post by:
I'm trying to add an IP address to a pc's network card. In C++ I used the IPHlpApi.lib's function AddIPAddress. Is there a built in way to add an IP Address in C#? Thanks in advance...
0
3756
by: nancylife | last post by:
When developing web report, many developers use VMware to simulate different operating systems on a same server. Then, they can realize cross-platform deployment and debug of web report. According to...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.