如何在C#windows应用程序中扫描条形码 [英] How to scan barcode in C# windows application

查看:264
本文介绍了如何在C#windows应用程序中扫描条形码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的应用程序中,我想使用条形码扫描仪扫描条形码并显示该数字以进行标记。我不明白如何在我的应用程序中使用它。



加载应用程序后我扫描条形码并将其显示在label.but应用程序如何知道扫描仪读取条形码。



我尝试了什么:



没有启动应用程序思考如何在应用程序中使用它。

Hi,

In my application i want to use Barcode Scanner which scan barcode and display that number to label. i dont understand how to use it in my application.

after loading application i scan barcode and display it in label.but how application know that scanner read barcode.

What I have tried:

not started application thinking on that how to use it in application.

推荐答案

您有三种选择:



1)USB条码扫描器将具有键盘仿真功能。这意味着,扫描的条形码将出现在您当前的输入光标处,就好像您已将数字/字符串手动键入键盘一样。所以你可以只有一个文本输入控件,如果它是输入来自的键盘或条形码扫描器,就不要打扰。优点:最容易设置。缺点:当用户想要扫描条形码时,您必须注意文本输入控件始终具有输入焦点。



2)条形码的制造商扫描仪MIGHT有一个API。对于低预算扫描仪,通常没有。优点:输入控制没有问题。缺点:您将应用程序限制为一种类型(或某些类型)的条形码扫描仪。比1)更多的工作



3)使用WindowsRaw Input API。在此CodeProject文章中进行了解释和演示:使用来自的原始输入C#处理多个键盘 [ ^ ]

优点:输入控件没问题。供应商特定的API没有问题。缺点:比1)更多的工作
You have three options:

1) A USB-barcode scanner will have keyboard emulation. Meaning, a scanned barcode will appear at your current input cursor as if you've typed the number/string manually into a keyboard. So you could just have a text input control and just don't bother if it's a keyboard or barcode scanner where the input comes from. Advantage: Easiest to set up. Disadvantage: You have to take care that the text input control always has the input focus when the user might want to scan a barcode.

2) The manufacturer of your barcode scanner MIGHT have an API for it. For low budget scanners there are most often none. Advantage: No trouble with an input control. Disadvantage: You're limiting your application to one type (or certain types) of barcode scanner. More work than for 1)

3) Use the Windows "Raw Input API". Explained and demonstrated in this CodeProject article: Using Raw Input from C# to handle multiple keyboards[^]
Advantage: No trouble with an input control. No trouble with vendor specific API's. Disadvantage: More work than for 1)


这篇关于如何在C#windows应用程序中扫描条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆