我一直在开发一个应用程序,现在我已经完成了检测 USB 设备(MASS STORAGE),但我需要做的是捕获该消息并且不要将其传递给 Windows。我想问一个密码,如果没问题,那么我想将消息传递给 Windows,否则丢弃它,,,我怎么能做到这一点,,,>
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case Win32.WM_DEVICECHANGE: OnDeviceChange(ref m); break;
}
base.WndProc (ref m);
}
void OnDeviceChange(ref Message msg)
{
int wParam = (int)msg.WParam;
if (wParam == Win32.DBT_DEVICEARRIVAL)
{
label1.Text = "Arrival";
//MessageBox.Show("" + wParam);
//msg = Message.Create(new IntPtr(),1,new IntPtr(),new IntPtr());
}
else if (wParam == Win32.DBT_DEVICEREMOVECOMPLETE) label1.Text =
"Remove";
}