我正在尝试将驱动器检测添加到我的程序中,但我遇到了一些困难。当我尝试使用此代码项目上指定的代码时。我目前正在为我的项目使用 Windows,但无法使其正常工作。
namespace Project
{
public partial class MainWindow : Window
{
OTHER CODE
private const int WM_DEVICECHANGE = 0x219;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_DEVICECHANGE:
// The WParam value identifies what is occurring.
// n = (int)m.WParam;
break;
}
base.WndProc(m);
}
}
}
对于 WndProc,我需要使用 System.Windows.Forms;但我也有使用 System.Windows.Controls; 这给了我以下错误
是 'System.Windows.Controls.MenuItem' 和 'System.Windows.Forms.MenuItem' 之间的模棱两可的引用
对于 base.WndProc(m); 我收到错误:“System.Windows.Window”不包含“WndProc”的定义
和 protected override void WndProc(ref Message m) 给出错误:'Project.MainWindow.WndProc(ref System.Windows.Forms.Message)':找不到合适的方法来覆盖
我显然做错了什么,但不确定是什么