标题:求解:如何利用条形码扫描数据进行检索
只看楼主
whinda
Rank: 6Rank: 6
等 级:贵宾
威 望:13
帖 子:253
专家分:418
注 册:2012-2-4
得分:0 
WMI方式检测:
    wmi = WIN32OLE.connect("winmgmts://")
    devices = wmi.ExecQuery("Select * From Win32_USBControllerDevice")
    devices.each do |device|
      device_name = device.Dependent.gsub('"', '').split('=')[1]
      usb_devices = wmi.ExecQuery("Select * From Win32_PnPEntity Where DeviceID = '#{device_name}'")
      for usb_device in usb_devices do
        puts usb_device.Description
        if usb_device.Description == 'USB Mass Storage Device'&&如是扫描枪的话应该是“XXXX SCANNER”之类
          # DO SOMETHING HERE
        end
      end
    end
2013-08-07 16:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-418454-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022397 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved