C#-XPEmbedded-MACAddress Nightmare

R

Rene

All I want is to retrieve the insonet little MAC address of my network
adapter using C#, the code that I was planning on using is as follows:



---------------------------------------------------------------------------

System.Management.ManagementClass mc = new
System.Management.ManagementClass("Win32_NetworkAdapterConfiguration");
System.Management.ManagementObjectCollection moc = mc.GetInstances();
foreach(System.Management.ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
MessageBox.Show(mo["MacAddress"].ToString());
}

---------------------------------------------------------------------------



If I run this code on aregular installation of Windows XP everything works
fine, but if I do it on my XPE image it crashes although I do include the
System.Management.dll file on the image. Can someone tell me what am I
missing? Can one of you try to run this code in your XPE image to see if you
get an error?



Note: You must include the "System.Management" in your project in order for
this code to work.



Thank you
 
G

Guest

Just to get the obvious out of the way, you need to make sure the .NET framework and WMI components are included in your XPe image. You can also get the MAC address using the GetAdaptersInfo C/C++ API. This will circumvent the .NET and WMI requirements

HTH
Tony
 
R

Rene

Could you please tell me the exact name of the WMI component I have to
include? A filter for WMI returned to many items I am not sure which on to
add.



Thank you.

Tony Camilli said:
Just to get the obvious out of the way, you need to make sure the .NET
framework and WMI components are included in your XPe image. You can also
get the MAC address using the GetAdaptersInfo C/C++ API. This will
circumvent the .NET and WMI requirements.
 
K

KM

Rene,

Start with "WMI Core" and "WMI Scripting". And resolve their dependencies.
You may also need "WMI Tools" in order to test how WMI works on your runtime.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top