Tuesday, December 8, 2009

How to get IP address with AIR 2.0 (windows version)

Previously it was quit difficult to get client's IP address from AIR application, but with AIR 2.0 SDK it is just few lines of code.

if (NativeProcess.isSupported)
var file:File = File.applicationDirectory;
file = file.resolvePath("c:\\WINDOWS\\system32\\ipconfig.exe");
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = file;
process = new NativeProcess(); process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);

private function onOutputData(event : ProgressEvent):void

As you can see this is Windows version. I am not very familiar (yet) with OSX native processes, but I am sure that there is a way to get IP address as well.
So, it is time to try some IP2GEO API. It will be fun :)

No comments:

Post a Comment