24. February 2009 20:59
.NET . WCF
Today I was helping a college get USB detection working on a WPF application. He was using a library I wrote for another windows forms application and was trying to use it in a WPF application.
The problem is that my library overrode the WndProc method of the main application form in order to capture and route the windows messages through to the library.
WPF does not natively have the WndProc as it uses a different messaging architecture, however an interop has been provided details of which can be found in "WPF and Win32 Interoperation Overview" and more "WPF-Win32 Interop Part 2: Hosting Win32 Controls (ListBox) in WPF Windows"
I’ve mentally bookmarked this subject to come back to as it looks like it gets involved but essentially if you want to detect the removal of a USB device in a WPF application you can do it by using the example I outline in this page. The example is a get you started and I would read around the subject before using this in production code.
Read all about U.B. Funkey USB Detection Example VB.NET & WPF