473,655 Members | 3,112 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 4554
"Bill McNeal" <Bi********@Bol .com.br> wrote in news:#ASu9Q#mDH A.3732
@tk2msftngp13.p hx.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.Manageme nt namespace to your code and then use
ManagementClass ("Win32_Network Adapter") 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.Manageme nt;
public class Wmis {
public static void Main() {
using (ManagementObje ct netw = new ManagementObjec t("Win32_Networ kAdapterConfigu ration.Index=1" ))
{
string s = netw["MACAddress "].ToString();
Console.WriteLi ne( "MAC Address\t‘{0}’" , s);
}
}
}
//Index = 1 is the adaptors configuration

Willy.
"Bill McNeal" <Bi********@Bol .com.br> wrote in message news:%2******** **********@tk2m sftngp13.phx.gb l...
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******** **********@tk2m sftngp13.phx.gb l...
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
2283
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 network card 2 is 192.0.0.2. The question is: Can the SQL server accept the connections(TCP/IP protocol) from the two network cards?
0
4558
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 others who are struggling with the same issues. This info exists in the groups, but not all in the same place. Thanks to everyone who contributes. Well done! Consider the following code:
0
2837
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 choose the network interface they want to send and receive UDP packets on. Simple enough. If the computer has a single network card and IP address this all works
2
9418
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 application to use this one to access the network. Thanks
3
6052
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++. Here's what I've found in C#: using System.Management; ..... ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
5
11153
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 what NIC it refers to the second one in the addresslist is the current one (mIpAddr(1).ToString()). How can I test for the current active IP address?? Many thanks in anticipation. Many thanks
1
1623
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 need to know which network adapter they came in on. (for reasons, I can only talk to the hardware using a certain network address on the physical card, so will need to reconfigure the card programatically (which I can already
2
1946
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 the app's speed drops to a crawl. If I split the app have and make sure the MDBs use file names 8 chars and have a persistent link to the backend it's almost as fast has having a non-split app on the network...we're talking almost a .1 to .5...
3
3545
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
3770
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 real application of web report, I will discuss three network setting ways of VMware with all of you. Bridge way This is the simplest way as it bridges the virtual network card to a physical network card directly. It is similar to a network...
0
8380
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7310
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2721
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 we have to send another system
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.