Reference: How to prevent autoplay and run my own app when inserting an USB-Flash drive
From a WPF app I need to suppress Autoplay for digital cameras I attach with a USB cable.
Thomas provided a good answer. I took Thomas’ working code and used it in a VS 2013 project where I created a new WPF Application. The sample App works great. I took the exact same code and put it into my real WPF application and the AllowAutoPlay procedure is never called. I did create a new Guid for the Autoplay class and registered it in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\CancelAutoplay\CLSID for my real app just like I did for the sample app.
What approach should I take to debug my WPF app? I dumped the Running Object Table to the Console, and it looks correct. I am much more familiar with the old Windows Forms Application structure where I would say some message is being missed or handled incorrectly.
I need some help how to debug this.
I tried dumping the Running Object Table and it looks correct. I tried Thomas’ code in a new WPF application it ran as expected.