简体   繁体   English

如何通过 C# 中的 USB 在设备与计算机之间建立连接

[英]How can i established a connection between a device with a Computer Machine via USB in C#

I am new to programming and i am trying to understand how to connect an external device with a Pc via USB.我是编程新手,我想了解如何通过 USB外部设备与 PC 连接。 Using C sharp as programming language使用 C 锐作为编程语言

How can i established a connection between a device with a Computer Machine via USB in C#如何通过 C# 中的 USB 在设备与计算机之间建立连接

It totally depends on the USB device and the driver.这完全取决于 USB 设备和驱动程序。

If you have no driver you first will need to have/make some sort of driver in order to communicate with the USB device.如果您没有驱动程序,您首先需要拥有/制作某种驱动程序才能与 USB 设备通信。 This cannot be done in C#.这不能在 C# 中完成。 You will need to write the driver in C or C++.您需要在 C 或 C++ 中编写驱动程序。 Writing drivers is a very tedious task and has an enormous learning curve to it.编写驱动程序是一项非常乏味的任务,并且有一个巨大的学习曲线。 If you are new to programming I wish you all the best.如果您是编程新手,我祝您一切顺利。 If you do decide to embark on this adventurous journey I would suggest looking for a open source general driver already written in C or C++ and see if you can expand on it.如果你决定开始这个冒险之旅,我建议你寻找一个已经用 C 或 C++ 编写的开源通用驱动程序,看看你是否可以扩展它。

If you do have a driver there might be some documentation of how you can interface with it to communicate with your USB device.如果您确实有驱动程序,可能会有一些文档说明您如何与它交互以与您的 USB 设备进行通信。 Or you can load the DLL in your assembly and see what interface it offers.或者您可以在您的程序集中加载 DLL 并查看它提供的接口。

Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM