954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Get physical address of interface[1]?

If I remember correctly from C# to C++ the following should convert into the second following. I need to create a console application that will output the physical address of the main interface on a user's computer. This in my experience seems to always be the second interface in the array of network interfaces within the NetworkInformation namespace.

using System.Net.NetworkInformation;

namespace test
{
private class testclass
{
private NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
private string pa = "";

private void main()
{
// Not 100% sure straight from memory but I know it's not that hard to find.
pa = interfaces[1].PhysicalAddress.ToString();
}
}
}


Converts to?

#include <iostream>
#include <string>

using namespace std;
using namespace System::Net::NetworkInformation;

int main()
{
// In c# * is for pointers and something tells me I'm confused. :(
NetworkInterface* interfaces = NetworkInterface->GetAllNetworkInterfaces();
cout << interfaces[1]->PhysicalAddress->ToString();
system("pause");
}


Please note, I haven't used C++ in years and don't remember hardly anything from it. I can do my basics that's about it. Most of the syntax still trips me up quite often.

float x1, x2;
cout << (int)(x1 / x2);


Those are what I consider basics, so any help here is appreciated. I'm taking a C++ class and don't have my class book. So any way that I can learn the material I'll take it.

Thanks,
Jamie

lxXTaCoXxl
Posting Whiz
300 posts since Mar 2011
Reputation Points: 22
Solved Threads: 18
 

These is not the article you are looking for. (Especially Method 3.)
http://www.codeguru.com/cpp/i-n/network/networkinformation/article.php/c5451

DeanMSands3
Junior Poster
186 posts since Jan 2012
Reputation Points: 37
Solved Threads: 27
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You