windows - Retrieve manufacturer information from device that AIR app is running on -
does know of way retrieve information manufacturer/model of device air app running on. capabilities class doesn't seem cut it.
the solution needs work air apps running on windows desktops or laptops, , needn't descriptive string of model - long piece of data unique specific model or device (or @ least specific manufacturer).
on windows, it's possible query motherboard's serial number wmic, or windows management instrumentation command-line. therefore, can pass command wmic baseboard serialnumber argument cmd.exe using flash.desktop.nativeprocess without need native extension.
since air nativeprocess api being used, must use extended desktop
application profile , package application 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 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 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 retreive motherboard's manufacturer, model number , serial number, can update string constant this:
//constants private static const motherboard_info:string = "wmic baseboard product, manufacturer, serialnumber";
[edit 2]
i learned following wmic command return name, vendor , identifying number of machine. sounds looking for:
//constants private static const csproduct_info:string = "wmic csproduct name, vendor, identifyingnumber";
however, keep in mind custom built pcs, such own, command returns nothing. well, not nothing, instead of 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
Comments
Post a Comment