Hi,
We are working on a USB device program. Following code snippet is my UsbComponent class. It works fine under windows XP or even windows 64 32bit. But under windows 7 64bit, PreFilterMessage never gets entered whenever I plugin/remove our USB device. Did I miss anything to make following code working under windows 7 64bit?
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
public partial class UsbComponent : Component, IMessageFilter {
private const int WM_DEVICECHANGE = 0x219;
public UsbComponent() {
InitializeComponent();
Application.AddMessageFilter( this );
}
public UsbComponent( IContainer container ) {
container.Add( this );
InitializeComponent();
Application.AddMessageFilter( this );
}
bool IMessageFilter.PreFilterMessage( ref Message m ) {
if( m.Msg == WM_DEVICECHANGE ) {
MessageBox.Show("device changed");
return true;
}
return false;
}
}