本文介绍了Retreive从设备的AIR应用程序正在运行的生产厂家信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道的方式来检索有关AIR应用程序上运行的设备的制造商/型号信息。 Capabilities类似乎并没有削减它。

Does anybody know of a way to retrieve information about the manufacturer/model of the device that the AIR app is running on. The Capabilities class doesn't seem to cut it.

只需要工作在Windows运行AIR应用将溶液桌面或便携式计算机,它不必是该模型的描述字符串 - 只要它是一块数据专用于特定模型或装置(或至少特别的制造商)。

The solution only needs to work for AIR apps running on Windows desktops or laptops, and it needn't be a descriptive string of the model - as long as it is a piece of data unique to a specific model or device (or at least the specific manufacturer).

在此先感谢。

推荐答案

在Windows中,这是可以查询主板上的序列号与WMIC,或者的。因此,你可以简单地传递命令的 WMIC踢脚线得到SERIALNUMBER 的作为参数的的cmd.exe 的使用 flash.desktop.NativeProcess 而不需要原生扩展。

On Windows, it's possible to query the motherboard's serial number with WMIC, or Windows Management Instrumentation Command-line. Therefore, you can simply pass the command wmic baseboard get serialnumber as an argument to cmd.exe using flash.desktop.NativeProcess without the need for a Native Extension.

由于空气的NativeProcess API正被使用,必须使用扩展桌面应用程序配置文件,并使用本机安装打包应用程序。

Since the AIR NativeProcess API is being used, you must use the Extended Desktop application profile and package your application with a native installer.

package 
{
    //Imports
    import flash.display.Sprite;
    import flash.display.StageScaleMode;
    import flash.display.StageAlign;
    import flash.desktop.NativeProcess;
    import flash.desktop.NativeProcessStartupInfo;
    import flash.events.ProgressEvent;
    import flash.filesystem.File;

    //Class
    [SWF(width = "600", height = "250", frameRate = "60", backgroundColor = "0x000000")]
    public class Main extends Sprite 
    {
        //Constants
        private static const MOTHERBOARD_SERIALNUMBER_COMMAND:String = "wmic baseboard get serialnumber";

        //Properties
        private var nativeProcess:NativeProcess;

        //Constructor
        public function Main():void 
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            init();
        }       

        //Init
        private function init():void
        {
            if (!NativeProcess.isSupported)
            {
                throw new Error("Native Process is not supported.");
            }

            var file:File = new File("C:\\Windows\\System32\\cmd.exe");

            var args:Vector.<String> = new Vector.<String>();
            args.push("/c");
            args.push(MOTHERBOARD_SERIALNUMBER_COMMAND);

            var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
            nativeProcessStartupInfo.executable = file;         
            nativeProcessStartupInfo.arguments = args;

            nativeProcess = new NativeProcess(); 
            nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, outputDataEventHandler);
            nativeProcess.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, outputErrorEventHandler);
            nativeProcess.start(nativeProcessStartupInfo);
        }

        //Output Data Event Handler
        private function outputDataEventHandler(event:ProgressEvent):void 
        { 
            var output:String = nativeProcess.standardOutput.readUTFBytes(nativeProcess.standardOutput.bytesAvailable);

            nativeProcess.exit();

            trace(output);
        }

        //Output Error Event Handler
        private function outputErrorEventHandler(event:ProgressEvent):void
        {
            nativeProcess.exit();

            throw new Error(event);
        }
    }
}


另外,如果你也想中检索的主板制造商,型号和序列号,您可以更新字符串常量这一点:

Alternatively, if you would also like to retreive the motherboard's manufacturer, model number and serial number, you can update the string constant to this:

//Constants
private static const MOTHERBOARD_INFO:String = "wmic baseboard get product, manufacturer, serialnumber";


我刚刚得知以下WMIC命令将返回一台机器的名称,供货商和标识号。这听起来正是你寻找的:

I just learned that the following WMIC command will return the name, vendor and identifying number of a machine. It sounds exactly what your looking for:

//Constants
private static const CSPRODUCT_INFO:String = "wmic csproduct get name, vendor, identifyingNumber";

但是,请记住,对于定制的电脑,比如我自己,这个命令返回什么。好了,不完全是没事的,而是一些典型的,如:

However, keep in mind that for custom built PCs, such as my own, this command returns nothing. Well, not exactly nothing, but instead of something typical like:

IdentifyingNumber  Name           Vendor
99L9891            Latitude D610  Dell Inc.

我的自定义生成回报的:

My custom build returns this:

IdentifyingNumber     Name                 Vendor
System Serial Number  System Product Name  System manufacturer

这篇关于Retreive从设备的AIR应用程序正在运行的生产厂家信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 09:36