0 Members and 1 Guest are viewing this topic.
(defun HDSerial ( drive / fso drv ser ) (vl-catch-all-apply (function (lambda nil (setq fso (vlax-create-object "Scripting.FileSystemObject") drv (vlax-invoke-method fso 'getdrive drive) ser (vlax-get-property drv 'serialnumber) ) ) ) ) (if drv (vlax-release-object drv)) (if fso (vlax-release-object fso)) ser)
(defun HDSerial ( / wmi srv drv ser ) (vl-catch-all-apply (function (lambda ( ) (if (setq wmi (vlax-create-object "WbemScripting.SWbemLocator") srv (vlax-invoke wmi 'connectserver nil nil nil nil nil nil nil nil) drv (vlax-invoke srv 'execquery "Select SerialNumber from Win32_DiskDrive") ) (vlax-for item drv (vlax-for prop (vlax-get item 'Properties_) (if (eq "SERIALNUMBER" (strcase (vlax-get prop 'name))) (setq ser (vl-string-trim " " (vlax-get prop 'value))) ) ) ) ) ) ) ) (if drv (vlax-release-object drv)) (if srv (vlax-release-object srv)) (if wmi (vlax-release-object wmi)) ser)
Keith, Lee Mac - Thanks. I'll start testing these to see what works best. Our user base ranges from XP thru Windows7, so I may have to test for OS platform to decide which to use. But, thanks again.
Quote from: laidbacklarry on May 28, 2011, 05:47:51 PMKeith, Lee Mac - Thanks. I'll start testing these to see what works best. Our user base ranges from XP thru Windows7, so I may have to test for OS platform to decide which to use. But, thanks again.You're welcome If available to you, another option would be to use DosLib's dos_serialno function.