是否有人知道检索有关运行AIR应用程序的设备的制造商/型号的信息的方法。 Capabilities类似乎没有削减它。
解决方案只需要适用于在Windows桌面或笔记本电脑上运行的AIR应用程序,并且它不必是模型的描述性字符串 - 只要它是特定模型或设备所特有的一段数据(或至少是具体的制造商。)
答案 0 :(得分:3)
在Windows上,可以使用WMIC或Windows Management Instrumentation Command-line查询主板的序列号。因此,您只需使用flash.desktop.NativeProcess将命令 wmic baseboard get serialnumber 作为参数传递给 cmd.exe ,而无需本机扩展。
由于正在使用AIR NativeProcess API,您必须使用Extended Desktop
应用程序配置文件并使用本机安装程序打包应用程序。
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);
}
}
}
<强> [编辑] 强>
或者,如果您还想检索主板的制造商,型号和序列号,您可以将字符串常量更新为:
//Constants
private static const MOTHERBOARD_INFO:String = "wmic baseboard get product, manufacturer, serialnumber";
[编辑2]
我刚刚了解到以下WMIC命令将返回计算机的名称,供应商和标识号。这听起来正是你所寻找的:
//Constants
private static const CSPRODUCT_INFO:String = "wmic csproduct get name, vendor, identifyingNumber";
但是,请记住,对于自定义构建的PC,例如我自己的PC,此命令不返回任何内容。嗯,不是什么都没有,而是一些典型的东西:
IdentifyingNumber Name Vendor
99L9891 Latitude D610 Dell Inc.
我的自定义构建会返回:
IdentifyingNumber Name Vendor
System Serial Number System Product Name System manufacturer