c# - 捕获使用的 USB 设备名称。VB.net
问题描述
我正在为旋转门创建一个 VB.Net 项目。我的问题是我需要知道使用了特定的 usb rfid 阅读器,以便我可以向旋转栅门发出命令,它将转向什么。例如,如果在 rfid 上点击 id 进入,它将转向进入。
我在互联网上看到过 C# 代码并尝试将其转换为 VB.Net,但不幸的是我迷路了。它使用 RawInputProcessor.dll
我发现的 C#:
protected override void OnSourceInitialized(EventArgs e)
{
_r = new RawPresentationInput(this, RawInputCaptureMode.Foreground);
_r.KeyPressed += OnKeyPressed;
DeviceCount = _r.NumberOfKeyboards;
base.OnSourceInitialized(e);
}
private void StartWndProcHandler()
{
_r = new RawPresentationInput(this, RawInputCaptureMode.Foreground);
_r.KeyPressed += OnKeyPressed;
DeviceCount = _r.NumberOfKeyboards;
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler propertyChanged = PropertyChanged;
if (propertyChanged != null)
{
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private void OnKeyPressed(object sender, RawInputEventArgs e)
{
if (this.IsActive)
{
Keyboard.ClearFocus();
Event = e;
DeviceCount = _r.NumberOfKeyboards;
if (Event.Device.Name == Configuration.device1_in && e.KeyPressState == KeyPressState.Up)
{
//do stuff for the turnstile
}
}
}
解决方案
推荐阅读
- django - 它实际上在做什么(data=request.data)?
- email - Outlook 2003 未正确呈现我们的 MJML 代码
- javascript - React 中的 SVG 图像大小
- google-app-maker - App Maker-记录出现在多个页面中(分页问题)
- javascript - 在库中获取文件(汇总)
- excel - 是否可以在使用 UserInterfaceOnly 锁定工作表后让 VBA 更改单元格内部颜色?
- firebase - 如何使用 sharedpreferences 保存用户角色并使用它们来保持用户登录并根据 Flutter 中的角色导航到特定页面
- pagespeed - 我应该信任谁来衡量网站速度?
- stata - 通过 Stata 15.1 版中的模拟进行功率分析
- lldb - 带有 clang 10 的 lldb Windows 错误