找到答案了:
public ref class Form1 : public System::Windows::Forms::Form
{
...
protected:
virtual void WndProc(System::Windows::Forms::Message% m) override;
...
}
void Form1::WndProc(System::Windows::Forms::Message% m)
{
if (m.Msg == WM_DEVICECHANGE)
{
switch (m.WParam.ToInt32())
{
case DBT_DEVICEARRIVAL:
break;
default:
break;
}
}
System::Windows::Forms::Form::WndProc(m);
return;
}