用于检测USB插入/移除的c ++控制台应用程序的问题 [英] Problem with c++ console application for Detecting USB Insertion/Removal

查看:59
本文介绍了用于检测USB插入/移除的c ++控制台应用程序的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在研究这个例子

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363432(v = vs.85).aspx

帮助我捕获了硬件中的任何变化。 (比如连接和断开USB闪存盘)



该示例说明为了使我的控制台项目能够编译此代码,我必须设置Project-> Properties - >链接器 - >系统 - > Windows子系统



我的主要问题是我要求项目像控制台应用程序一样。

有没有办法通过控制台应用程序运行此代码,还是我应该使用全新的策略?



谢谢

Currently I'm working on this example
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363432(v=vs.85).aspx
that helped me capture any changes in my hardware. (Like connecting and disconnecting a USB flash drive)

The sample explains that in order to enable my console project to compile this code I had to set Project->Properties->Linker->System->Subsystem to Windows

My main problem is that I require the project to stay like a console application.
Is there any way to run this code by a console application or shall I be using a whole new strategy?

Thanks

推荐答案

正如文章所述,您只能通过Windows消息泵接收这些通知。该功能在控制台应用程序中不可用。
As the article makes clear, you can only receive these notifications through a Windows message pump. That feature is not available in console applications.


这篇关于用于检测USB插入/移除的c ++控制台应用程序的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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