ref: http://www.codeguru.com/cpp/i-n/network/networkinformation/article.php/c5451/Three-ways-to-get-your-MAC-address.htm
Note: this function works for windows 2000/xp or above only... and if there are more than one network cards, this function only get the first one... for example:, if vmare workstation exists, this function will return a mac address for vmnet8 in my machine..
use GetAdaptersInfo instead to retrieve all nic info
#include <string>
#include <windows.h>
#include "boost/format.hpp"
using namespace std;
using boost::format;
using boost::io::str;
string getMac()
{
unsigned char MACData[6];
UUID uuid;
UuidCreateSequential(&uuid);
for(int i = 2; i<8; ++i)
{
MACData[i-2] = uuid.Data4[i];
}
format f("%02X-%02X-%02X-%02X-%02X-%02X");
f % (int)MACData[0] % (int)MACData[1] %(int)MACData[2] %(int)MACData[3] %(int)MACData[4] %(int)MACData[5];
return f.str();
}
link Rpcrt4.lib...
分享到:
相关推荐
Delegating Automatically as an Alternative to Inheritance Recipe 6.6. Delegating Special Methods in Proxies Recipe 6.7. Implementing Tuples with Named Items Recipe 6.8. Avoiding Boilerplate ...
unknownFiles - Used to record name/location of non-standard files in an apk in order to place correctly on rebuilt apk sharedLibrary - Used to help support Android 5 shared library feature by ...
**1.6 Is Maven an Alternative to XYZ?** Maven is often compared to other build tools like Ant and Gradle. While each tool has its strengths, Maven offers a unique approach to project management and ...
// - To get a BufferedImage from an IplImage, or vice versa, we can chain calls to // Java2DFrameConverter and OpenCVFrameConverter, one after the other. // - Java2DFrameConverter also has static ...