最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net识别u盘实例代码
时间:2022-06-25 05:07:18 编辑:袖梨 来源:一聚教程网
asp教程.net识别u盘实例代码
using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.io;namespace usb
{
public partial class form1 : form
{
public const int wm_devicechange = 0x219;
public const int dbt_devicearrival = 0x8000;
public const int dbt_configchangecanceled = 0x0019;
public const int dbt_configchanged = 0x0018;
public const int dbt_customevent = 0x8006;
public const int dbt_devicequeryremove = 0x8001;
public const int dbt_devicequeryremovefailed = 0x8002;
public const int dbt_deviceremovecomplete = 0x8004;
public const int dbt_deviceremovepending = 0x8003;
public const int dbt_devicetypespecific = 0x8005;
public const int dbt_devnodes_changed = 0x0007;
public const int dbt_querychangeconfig = 0x0017;
public const int dbt_userdefined = 0xffff;public form1()
{
initializecomponent();
}private void form1_load(object sender, eventargs e)
{}
protected override void wndproc(ref message m)
{
try
{
if (m.msg == wm_devicechange)
{
switch (m.wparam.toint32())
{
case wm_devicechange://
break;
case dbt_devicearrival://u盘插入
driveinfo[] s = driveinfo.getdrives();
foreach (driveinfo drive in s)
{
if (drive.drivetype == drivetype.removable)
{
richtextbox1.appendtext("u盘已插入,盘符为:" + drive.name.tostring() + "rn");
break;
}
}
break;
case dbt_configchangecanceled:
messagebox.show("2");
break;
case dbt_configchanged:
messagebox.show("3");
break;
case dbt_customevent:
messagebox.show("4");
break;
case dbt_devicequeryremove:
messagebox.show("5");
break;
case dbt_devicequeryremovefailed:
messagebox.show("6");
break;
case dbt_deviceremovecomplete: //u盘卸载
richtextbox1.appendtext("u盘已卸载,盘符为:");
break;
case dbt_deviceremovepending:
messagebox.show("7");
break;
case dbt_devicetypespecific:
messagebox.show("8");
break;
case dbt_devnodes_changed://可用,设备变化时
messagebox.show("9");
break;
case dbt_querychangeconfig:
messagebox.show("10");
break;
case dbt_userdefined:
messagebox.show("11");
break;
default:
break;
}
}
}
catch (exception ex)
{
messagebox.show(ex.message);
}
base.wndproc(ref m);
}private void button1_click(object sender, eventargs e)
{
}}
}%>
相关文章
- 《燕云十六声》红尘无眼完成图文攻略 12-25
- 《燕云十六声》阴阳如影完成图文攻略 12-25
- 《燕云十六声》悬檐之下四架椽屋图文攻略 12-25
- 《燕云十六声》2024最新公测时间介绍 12-25
- 《燕云十六声》有没有藏宝阁 12-25
- 《燕云十六声》制作公司介绍 12-25