开发者

How to reliable check if AutoPlay is enabled in Windows 7?

I have an application that handles WM_DEVICECHANGE, and is interested in DBT_DEVICEARRIVAL. When a new device is inserted, it needs to know if the AutoPlay dialog will pop-up. In order to find out, I am checking the values of NoDriveAutoRun and NoDriveTypeAutoRun in

SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer

under HKCU and HKLM. However, if a user goes to the "Control Panel -> AutoPlay" and unchecks "Use AutoPlay for all media and devices", then the AutoPlay is effectively disabled, but those registry values are not set. On my test box they aren't even there by default. And I believe that most users would use the Control Panel approach to disable the AutoPlay, rather than the Local Group Policy Editor.

So, my question is, what is 开发者_C百科that check mark setting (a registry value somewhere i suppose?). No matter what I try, I can't seem to (reliably) figure out if the AutoPlay is enabled or not.


It seems like an "AutoPlay" verb appears on the CD-ROM drive context menu when AutoPlay is enabled. So you could test for that.

  • Get an interface pointer to the shell IContextMenu for your CD-ROM drive, using IShellFolder::GetUIObjectOf
  • Use GetCommandString to walk through the list of verbs, looking for "AutoPlay"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜