禁止自动播放

禁止自动播放

问题描述:

我需要抑制大容量存储设备的自动播放.这需要通过在后台运行的服务/守护程序以编程方式实现.

I need to suppress autoplay for the mass storage devices. This needs to be achieved programatically through a service/deamon running in the background.

我知道这可以通过打开一个窗口并处理 Windows 发送的queryCancelAutoPlay"消息的应用程序来完成.

I know it can be done by an application which opens a window and handles the "queryCancelAutoPlay" message sent by windows.

这可以在没有 GUI 的情况下完成吗.我有需要禁用自动播放的设备的 guid/pid/vid.

Can this be done without GUI.I have the guid/pid/vid for the device whose autoplay needs to be disabled.

好的.您可以创建仅消息窗口.这给你一个 HWND 没有那些烦人的 WM_PAINT 消息等.另一种方法是使用 COM,IQueryCancelAutoplay

Sure. You can create a message-only window. That gives you a HWND without those annoying WM_PAINT messages etc. The other way is to use COM, IQueryCancelAutoplay