zoukankan      html  css  js  c++  java
  • as3调用外部应用程序 as调用外部exe文件as3调用bat文件 未测试 调用exe 已测试通过

    调用exe的时候会报错。具体方法:https://www.cnblogs.com/dt1991/p/11081848.html


    private function callTest(event: Event): void
    {
    callExe("d:/a.exe");
    callBat("d:/a.bat");
    }


    private function callExe(extUrl: String): void
    {
    //使用静态属性 NativeApplication.nativeApplication 获取应用程序的 NativeApplication 实例
    //指定在关闭所有窗口后是否应自动终止应用程序。

    NativeApplication.nativeApplication.autoExit = true;
    //调用的文件
    var file: File = new File();
    file = file.resolvePath(extUrl);
    var nativeProcessStartupInfo: NativeProcessStartupInfo = new NativeProcessStartupInfo();
    nativeProcessStartupInfo.executable = file;
    var process: NativeProcess = new NativeProcess();
    process.start(nativeProcessStartupInfo);
    }


    public static function callBat(batUrl: String): void
    {
    //调用bat文件
    var exePath: String = "C:/Windows/system32/cmd.exe"; //cmd的路径
    var info: NativeProcessStartupInfo = new NativeProcessStartupInfo(); //启动参数
    info.executable = new File(exePath);
    //参数
    var processArg: Vector.<<span style="color:#2aa198;font-weight:bold;">String> = new Vector.<<span style="color:#2aa198;font-weight:bold;">String>();
    processArg[0] = "/c"; //加上/c,是cmd的参数
    processArg[1] = batUrl; //bat的路径
    info.arguments = processArg;
    //执行
    var process: NativeProcess = new NativeProcess();
    process.addEventListener(NativeProcessExitEvent.EXIT, packageOverHandler);
    process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, outputHandler);
    process.start(info);
    }


    private static function outputHandler(event: ProgressEvent): void
    {
    trace("outputHandler");
    }


    private static function packageOverHandler(event: NativeProcessExitEvent): void
    {
    trace("packageOverHandler event: NativeProcessExitEvent");
    }

    http://blog.sina.com.cn/s/blog_73bed4520102w69z.html
  • 相关阅读:
    Swift 编程语言新手教程
    标准差(standard deviation)和标准错误(standard error)你能解释一下?
    shell文字过滤程序(十一):paste命令
    java 获取系统变量(环境变量和环境变量)
    MD5算法原理
    受托停止事件冒泡
    搜索引擎优化要领:8条辅助技巧(三)
    几种更新(Update语句)查询的方法
    学习盲点
    2014年同年CFA考试中哪些CFA资料没有变化?
  • 原文地址:https://www.cnblogs.com/dt1991/p/10336936.html
Copyright © 2011-2022 走看看