如何获得ipad的MAC地址 如何获得ipad的MAC地址 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #include <sys/types.h>#include <stdio.h>#include <string.h>#include <sys/socket.h>#include <net/if_dl.h>#include <ifaddrs.h>char* getMacAddress(char* macAddress, char* ifName) {int success;struct ifaddrs * addrs;struct ifaddrs * cursor;const struct sockaddr_dl * dlAddr;const unsigned char* base;int i;success = getifaddrs(&addrs) == 0;if (success) { cursor = addrs; while (cursor != 0) { if ( (cursor->ifa_addr->sa_family == AF_LINK) && (((const struct sockaddr_dl *) cursor->ifa_addr)->sdl_type == IFT_ETHER) && strcmp(ifName, cursor->ifa_name)==0 ) { dlAddr = (const struct sockaddr_dl *) cursor->ifa_addr; base = (const unsigned char*) &dlAddr->sdl_data[dlAddr->sdl_nlen]; strcpy(macAddress, ""); for (i = 0; i < dlAddr->sdl_alen; i++) { if (i != 0) { strcat(macAddress, ":"); } char partialAddr[3]; sprintf(partialAddr, "%02X", base[i]); strcat(macAddress, partialAddr); } } cursor = cursor->ifa_next; } freeifaddrs(addrs);} return macAddress;}char* macAddressString= (char*)malloc(18);NSString* macAddress= [[NSString alloc] initWithCString:getMacAddress(macAddressString,"en0") encoding:NSMacOSRomanStringEncoding];您应该是问怎么写代码取得吧??不是问怎么从设定找 getMacAddress第二个参数ifName是什么意思 ios 5.0应用转到6.0屏幕大小不一样怎么办? xcode怎么调用dylib 怎样找出NSString中字母 数字 中文 特殊字符的个数? tableView ,分组表 标题设置 Iphone通讯录的问题 EGORefreshTableHeaderView 下拉刷新 如何为UIToolbar动态添加按钮 ios 获取当前显示页面的控制器 导航栏自定义按钮加载图片问题,诚心求教 iphone被偷了 想用iBackupBot看备份 但是在导入时出现问题 求帮助!急急急 虚拟机中的键盘和鼠标都没有反应了 ★★Aptana Studio 3开发iPhone★★
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <net/if_dl.h>
#include <ifaddrs.h>
char* getMacAddress(char* macAddress, char* ifName) {int success;
struct ifaddrs * addrs;
struct ifaddrs * cursor;
const struct sockaddr_dl * dlAddr;
const unsigned char* base;
int i;success = getifaddrs(&addrs) == 0;
if (success) {
cursor = addrs;
while (cursor != 0) {
if ( (cursor->ifa_addr->sa_family == AF_LINK)
&& (((const struct sockaddr_dl *) cursor->ifa_addr)->sdl_type == IFT_ETHER) && strcmp(ifName, cursor->ifa_name)==0 ) {
dlAddr = (const struct sockaddr_dl *) cursor->ifa_addr;
base = (const unsigned char*) &dlAddr->sdl_data[dlAddr->sdl_nlen];
strcpy(macAddress, "");
for (i = 0; i < dlAddr->sdl_alen; i++) {
if (i != 0) {
strcat(macAddress, ":");
}
char partialAddr[3];
sprintf(partialAddr, "%02X", base[i]);
strcat(macAddress, partialAddr); }
}
cursor = cursor->ifa_next;
} freeifaddrs(addrs);
}
return macAddress;
}char* macAddressString= (char*)malloc(18);
NSString* macAddress= [[NSString alloc] initWithCString:getMacAddress(macAddressString,"en0")
encoding:NSMacOSRomanStringEncoding];您应该是问怎么写代码取得吧??
不是问怎么从设定找