获取OSX连接的Wi-Fi网络名称 [英] Getting OSX Connected Wi-Fi Network Name
问题描述
我需要获取OSX上当前连接的Wi-Fi SSID的名称.
I need to get the name of the currently connected Wi-Fi SSID on OSX.
我搞砸了SystemConfiguration框架,感觉好像在那里(因为我能够获得网络位置的名称),但是我并没有真正找到获取Wi-Fi SSID的方法.
I've messed with the SystemConfiguration framework, I feel like it is there (as I am able to get the name of the network locaiton) but I am not really finding a way of getting the Wi-Fi SSID.
非常感谢您的帮助. :)
Would appreciate any help. :)
谢谢.
推荐答案
您可以使用CoreWLAN框架:CWInterface
具有一个名为ssid
的属性.下面的代码获取当前的无线接口,并显示其BSD名称和SSID.它可以在Mac OS 10.6+上运行.
You can use the CoreWLAN framework: CWInterface
has a property called ssid
. The code below gets the current wireless interface and shows its BSD name and its SSID. It works on Mac OS 10.6+.
#import <Foundation/Foundation.h>
#import <CoreWLAN/CoreWLAN.h>
int main() {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
CWInterface *wif = [CWInterface interface];
NSLog(@"BSD if name: %@", wif.name);
NSLog(@"SSID: %@", wif.ssid);
[pool drain];
return 0;
}
输出:
$ ./wif
BSD if name: en1
SSID: Aetherius
这篇关于获取OSX连接的Wi-Fi网络名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!