资源简介

C#+串口和USB通信编程(代码)C#+串口和USB通信编程(代码)C#+串口和USB通信编程(代码) C#+串口和USB通信编程(代码)C#+串口和USB通信编程(代码)C#+串口和USB通信编程(代码)

资源截图

代码片段和文件信息

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() + “\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盘卸载
                            richTextBox1.AppendText(“U盘已卸载,盘符为:“);
                            break;
                        case DBT_DEVICEREMOVEPENDING:
      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        922  2008-06-24 11:47  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort.sln

    ..A..H.     14848  2008-06-27 09:56  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort.suo

     文件       6820  2008-06-24 16:00  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Form1.cs

     文件       4747  2008-06-24 14:29  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Form1.Designer.cs

     文件       6008  2008-06-24 14:29  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Form1.resx

     文件       3229  2008-06-24 12:00  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\HexCommPort.csproj

     文件        470  2008-06-24 11:47  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Program.cs

     文件      24576  2008-06-24 16:00  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\bin\Debug\HexCommPort.exe

     文件      26112  2008-06-24 16:00  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\bin\Debug\HexCommPort.pdb

     文件       5632  2005-12-08 14:51  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\bin\Debug\HexCommPort.vshost.exe

     目录          0  2008-07-04 12:41  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\bin\Debug

     目录          0  2008-07-04 12:41  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\bin

     文件        296  2008-06-27 09:54  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj\HexCommPort.csproj.FileList.txt

     文件        842  2008-06-24 14:29  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj\Debug\HexCommPort.csproj.GenerateResource.Cache

     文件      24576  2008-06-24 16:00  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj\Debug\HexCommPort.exe

     文件        180  2008-06-24 14:29  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj\Debug\HexCommPort.Form1.resources

     文件      26112  2008-06-24 16:00  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj\Debug\HexCommPort.pdb

     文件        180  2008-06-24 12:00  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj\Debug\HexCommPort.Properties.Resources.resources

     目录          0  2008-07-04 12:41  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj\Debug\Refactor

     目录          0  2008-07-04 12:41  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj\Debug\TempPE

     目录          0  2008-07-04 12:41  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj\Debug

     目录          0  2008-07-04 12:41  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\obj

     文件       1184  2008-06-24 11:47  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Properties\AssemblyInfo.cs

     文件       2876  2008-06-24 11:47  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Properties\Resources.Designer.cs

     文件       5612  2008-06-24 11:47  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Properties\Resources.resx

     文件       1094  2008-06-24 11:47  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Properties\Settings.Designer.cs

     文件        249  2008-06-24 11:47  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Properties\Settings.settings

     目录          0  2008-07-04 12:41  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort\Properties

     目录          0  2008-07-04 12:41  C# 串口和USB通信编程\串口\HexCommPort\HexCommPort

     目录          0  2008-07-04 12:41  C# 串口和USB通信编程\串口\HexCommPort

............此处省略75个文件信息

评论

共有 条评论