473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how to retreive the MAC address ?

of the net interface ?

thanks
Nov 17 '05 #1
3 2945
Hi Herbert,

One of the ways is to use the unmanaged Netbios() function from netapi32.dll
through P/Invoke.
You can find more information in the following MSDN article:

'Getting the MAC Address for an Ethernet Adapter' in Platform SDK: Netbios

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Herbert VON GRÜNENWALD" <he*******************@microsoft.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
of the net interface ?

thanks


Nov 17 '05 #2
Hi!
Use the code below:

System.Management.SelectQuery sq = new
System.Management.SelectQuery("Win32_NetworkAdapte rConfiguration",
"IPEnabled='TRUE'");

System.Management.ManagementObjectSearcher searcher = new
System.Management.ManagementObjectSearcher(sq);

foreach (System.Management.ManagementObject mos in searcher.Get())

{

MessageBox.Show(mos.GetPropertyValue("MACAddress") .ToString());

}

Hope that helps.

Best regards, Adrian.
Nov 17 '05 #3
Adrian wrote:
Hi!
Use the code below:

System.Management.SelectQuery sq = new
System.Management.SelectQuery("Win32_NetworkAdapte rConfiguration",
"IPEnabled='TRUE'");

System.Management.ManagementObjectSearcher searcher = new
System.Management.ManagementObjectSearcher(sq);

foreach (System.Management.ManagementObject mos in searcher.Get())

{

MessageBox.Show(mos.GetPropertyValue("MACAddress") .ToString());

}

Hope that helps.

Best regards, Adrian.

thanks, i've found another way:

ManagementObjectSearcher query = null;
ManagementObjectCollection queryCollection = null;

try
{
query = new ManagementObjectSearcher("SELECT * FROM
Win32_NetworkAdapterConfiguration") ;

queryCollection = query.Get();
foreach( ManagementObject mo in queryCollection )
{
if((bool)mo["IPEnabled"] == true)
{
Console.WriteLine(mo.GetText(TextFormat.Mof));
Console.WriteLine(mo["MacAddress"]);
}
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
Nov 17 '05 #4

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

Similar topics

0
by: Lee | last post by:
Hello, This is a genral enquiry before I send out a more detailed request. I am unable to retreive image files from a mysql database using IE 5.2 on the mac OS X platform. I have built a...
3
by: Not4u | last post by:
I would like to know which products are my best sells by sellers, but i would like to retreive this info by product id, seller id and the total amount of sells for this product. My Sells table...
3
by: Chris | last post by:
Hi, i would like to create a program which logs information which can then be retreived over the internet as an xml file. Basically i would retrieve the data by using an ip address, and...
7
by: Michael Maes | last post by:
Hello, How would I retreive only the numbers out of a string? Regex.Replace(mString, -Expression-, "") eg: mString = "AZE|@#{1^2#{[^3ert/.?" should return '123' TIA, Michael
1
by: Sudhakara.T.P. | last post by:
Hi, I have an application in VB.NET windows application, wherein the administrator has the option to change the authentication mode ie., whether the application should work as a normal database...
3
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer>...
0
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer>...
4
by: AkMaLiTo | last post by:
hi... i am in a mess, i need to use visual basic 6 with sql server 2000 database.. could someone tell me the best component to use with sql ? the project is as follow: retreive table names in a...
2
by: Doken13 | last post by:
I got an intranet web site and there is a proxy on the network. I want to retreive a client's IP, how could I get it ?
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.