flex4.6做的 一个系统操作小工具
private function runProcess():void{if (!NativeProcess.isSupported){Alert.show("当前系统不支持");return;}try{var file:File;// Use default paths for ping... modify if your system does not use the default pathif (Capabilities.os.toLowerCase().indexOf("win") > -1){file = new File("c://windows//system32//cmd.exe");}else if (Capabilities.os.toLowerCase().indexOf("mac") > -1){//}else if (Capabilities.os.toLowerCase().indexOf("linux") > -1){//}var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();nativeProcessStartupInfo.executable = file;process = new NativeProcess();process.start(nativeProcessStartupInfo);process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, stdoutHandler);process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA,errorHandler);}catch (e:Error){Alert.show(e.message, "Error");}}private function stdoutHandler(event:ProgressEvent):void{var process:NativeProcess = event.target as NativeProcess;var data:String = process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);}private function errorHandler(event:ProgressEvent):void{var process:NativeProcess = event.target as NativeProcess;var data:String = process.standardError.readUTFBytes(process.standardError.bytesAvailable);}
?
?如果对这个有兴趣的话,可以到我的个人网站有源文件的下载地址
1 楼 maxliz 18 小时前 flex做不了吧?只能AIR来做吧? 2 楼 clschen 17 小时前 maxliz 写道flex做不了吧?只能AIR来做吧?