方法1:
//USB设备感应模块(应用底层较为代码)
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x219)
{
if (m.WParam.ToInt32() == 0x8000)
{
DriveInfo[] allDrivers = DriveInfo.GetDrives();
foreach (var d in allDrivers) // 系统会自动扫描包含C:\\ 之类的,以及我们插入的U盘和移动硬盘
{
if (allDrivers[i].IsReady)
if (d.IsReady)
{
//USB设备感应模块(应用底层较为代码)
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x219)
{
if (m.WParam.ToInt32() == 0x8000)
{
DriveInfo[] allDrivers = DriveInfo.GetDrives();
foreach (var d in allDrivers) // 系统会自动扫描包含C:\\ 之类的,以及我们插入的U盘和移动硬盘
{
if (allDrivers[i].IsReady)
if (d.IsReady)
{
if (allDrivers[i].DriveType == DriveType.Removable) //查找到的是移动式的 磁盘
{
//(在这里填写你需处理的代码)