如何在USB插入触发事件 [英] How to Trigger an event when usb is plugged

查看:337
本文介绍了如何在USB插入触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了每当我的嵌入式设备连接到笔记本电脑的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.


  1. 所以,我必须在USB连接检测触发事件

  1. 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:


  1. 单击在Windows开始按钮。

  2. 单击控制面板。

  3. 单击网络连接。

  4. 单击创建一个新的连接。

  5. 选择选项设置高级连接。

  6. 选择选项直接连接到另一台计算机。

  7. 选择客户选项。给一个名称USB网络连接(例如连接名称)。

  8. :选择对应的PC上创建的最后一个COM端口通讯端口(COM X)

  9. 选择选项所有用户。

  10. 单击快捷方式添加到该连接到我的桌面,然后确定。

什么是我可以实现自动拨号连接方式?

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屋!

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