如何在USB插入触发事件 [英] How to Trigger an event when usb is plugged
问题描述
我已经开发了每当我的嵌入式设备连接到笔记本电脑的USB端口,这将创建一个虚拟COM端口设备驱动程序。
I have developed a device driver which will create a virtual com port whenever my embedded device is connected to the USB port of the laptop.
现在我需要创建一个自动拨号或新的网络连接与虚拟COM端口创建只要设备被插入到笔记本电脑。
Now I need to create an Auto Dial-Up or new network connection with the virtual com port created whenever the device gets plugged into the laptop.
-
所以,我必须在USB连接检测触发事件
So I have to trigger an event upon USB connection detection
在触发事件应该创建一个自动拨号与vitual端口连接建立(如:COM11)。
The triggered event should create an auto dial up connection with the vitual port created(eg:COM11).
步骤来创建新的自动拨号连接:
Steps to create a New Auto Dial Up connection:
- 单击在Windows开始按钮。
- 单击控制面板。
- 单击网络连接。
- 单击创建一个新的连接。
- 选择选项设置高级连接。
- 选择选项直接连接到另一台计算机。
- 选择客户选项。给一个名称USB网络连接(例如连接名称)。
- :选择对应的PC上创建的最后一个COM端口通讯端口(COM X)。
- 选择选项所有用户。
- 单击快捷方式添加到该连接到我的桌面,然后确定。
什么是我可以实现自动拨号连接方式?
What are the ways I can achieve an auto dial up connection?
以上可以在任何编程语言,preferaballyC / C ++来完成,因为我知道只有这两个。
The above can be done in any programming language, preferabally "C/C++", Since I know only those two.
推荐答案
您可以实现使用RASDIAL API函数拨号连接。请参阅指导这个项目。您可以创建一个窗口,它使用的 RegisterDeviceNotification
并听WM_DEVICECHANGE。你可以看到这个项目太一个例子。好运
You can achieve dialup connections using the RasDial API functions. See this project for a guide. You can create a window, register it using RegisterDeviceNotification
and listen for WM_DEVICECHANGE. You can see this project too for an example. Good Luck
这篇关于如何在USB插入触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!