M
Mark Prenter
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");
ManagementObjectCollection moc = mc.GetInstances();
foreach(ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
Console.WriteLine("MAC address\t{0}", mo["MacAddress"].ToString());
mo.Dispose();
}
Now, I'm trying to convert this to make it usable in C++, but the second
line has me thrown for a loop. Here's the beginning of what I've got :
#using <system.management.dll>
using namespace System::Management;
int _tmain(void)
{
ManagementClass* mc = new
ManagementClass("Win32_NetworkAdapterConfiguration");
return 0;
}
But even this won't compile....giving me the error
"System::ComponentModel::Component", the compiler cannot find this type; it
is defined in the assembly 'System'
Can anyone help me out with this? Please? I'm losing hair by the hour.
/\/\ark
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");
ManagementObjectCollection moc = mc.GetInstances();
foreach(ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
Console.WriteLine("MAC address\t{0}", mo["MacAddress"].ToString());
mo.Dispose();
}
Now, I'm trying to convert this to make it usable in C++, but the second
line has me thrown for a loop. Here's the beginning of what I've got :
#using <system.management.dll>
using namespace System::Management;
int _tmain(void)
{
ManagementClass* mc = new
ManagementClass("Win32_NetworkAdapterConfiguration");
return 0;
}
But even this won't compile....giving me the error
"System::ComponentModel::Component", the compiler cannot find this type; it
is defined in the assembly 'System'
Can anyone help me out with this? Please? I'm losing hair by the hour.
/\/\ark