1
votes

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.

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).

1
I've never seen anything like this in the AIR SDK. My personal guess is you would either have to write an ANE to handle it or it simply isn't possible. I'm not even sure where such information would be stored, honestly. Doesn't seem like something they would spend time modifying Windows to include. Not to mention that you wouldn't be able to get anything for custom builds. - Josh
If you're interested in the manufacturer of the network card I can elaborate an answer for results such as "Hon Hai Precision Ind. Co., Ltd." or "Quanta Computer Inc." for my wireless/ethernet adapters respectively. This will require you include a 1~ -> 2~ mb file with your app. - chadiik

1 Answers

3
votes

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.

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);
        }
    }
}

[EDIT]

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";

[EDIT 2]

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