-
大小: 168KB文件類(lèi)型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-15
- 語(yǔ)言: C#
- 標(biāo)簽: C#??USB??數(shù)據(jù)接收??發(fā)送數(shù)據(jù)??winform??
資源簡(jiǎn)介
C# USB數(shù)據(jù)接收與發(fā)送,可以作參考學(xué)習(xí)之用。

代碼片段和文件信息
//Download?by?http://www.NewXing.com
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盤(pán)插入
????????????????????????????DriveInfo[]?s?=?DriveInfo.GetDrives();
????????????????????????????foreach?(DriveInfo?drive?in?s)
????????????????????????????{
????????????????????????????????if?(drive.DriveType?==?DriveType.Removable)
????????????????????????????????{
????????????????????????????????????richTextBox1.AppendText(“U盤(pán)已插入,盤(pán)符為:“?+?drive.Name.ToString()?+?“\r\n“);
????????????????????????????????????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盤(pán)卸載
????????????????????????????richTextBox1.AppendText(“U盤(pán)已卸載,盤(pán)符為:“);
????????????????????????????break;
???????????????????????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
????.......?????55167??1999-12-15?19:58??VBUsb\CY7C63000\usbhidio.asm
????.......??????2862??1999-11-26?15:05??VBUsb\CY7C63000\usbhidio.hex
????.......?????89711??1999-11-26?15:05??VBUsb\CY7C63000\usbhidio.lst
????.......??????3650??1999-11-26?15:05??VBUsb\CY7C63000\usbhidio.rom
????.......??????1465??1999-12-15?21:17??VBUsb\usbhidio.inf
?????文件???????7716??2013-01-12?23:06??VBUsb\VisualBasic\ApiDeclarations.bas
?????文件??????27466??2013-01-12?23:06??VBUsb\VisualBasic\frmMain.frm
????.......?????49152??1999-12-15?21:30??VBUsb\VisualBasic\usbhidio.exe
?????文件????????879??2013-01-12?23:06??VBUsb\VisualBasic\usbhidio.vbp
????.......????????90??2004-03-28?15:35??VBUsb\VisualBasic\usbhidio.vbw
?????文件???????4141??2013-01-12?23:06??USB\Form1.cs
?????文件???????2666??2013-01-12?23:06??USB\Form1.Designer.cs
????.......??????5814??2007-09-15?12:51??USB\Form1.resx
????.......???????240??2008-07-01?10:20??USB\obj\USB.csproj.FileList.txt
?????文件????????500??2013-01-12?23:06??USB\Program.cs
?????文件???????1200??2013-01-12?23:06??USB\Properties\AssemblyInfo.cs
?????文件???????2898??2013-01-12?23:06??USB\Properties\Resources.Designer.cs
????.......??????5612??2007-09-15?10:35??USB\Properties\Resources.resx
?????文件???????1124??2013-01-12?23:06??USB\Properties\Settings.Designer.cs
????.......???????249??2007-09-15?10:35??USB\Properties\Settings.settings
????.......??????3213??2007-09-15?10:37??USB\USB.csproj
????.......???????894??2007-09-15?10:36??USB\USB.sln
????..A..H.?????12288??2008-07-01?10:36??USB\USB.suo
?????文件???????4544??2013-01-12?23:06??UsbEject\About.cs
????.......?????43688??2006-03-19?12:39??UsbEject\About.resx
?????文件????????783??2013-01-12?23:06??UsbEject\AssemblyInfo.cs
????.......????171819??2006-03-19?13:07??UsbEject\Icons.resx
?????文件???????8615??2013-01-12?23:06??UsbEject\Library\Device.cs
?????文件????????998??2013-01-12?23:06??UsbEject\Library\DeviceCapabilities.cs
?????文件???????9000??2013-01-12?23:06??UsbEject\Library\DeviceClass.cs
............此處省略30個(gè)文件信息
評(píng)論
共有 條評(píng)論