• 大小: 0.07M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-04-29
  • 语言: C#
  • 标签: usb  sb  C#  

资源简介

C# USB HIF

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;             // required for Message
using System.Runtime.InteropServices;   // required for Marshal
using System.IO;
using Microsoft.Win32.SafeHandles;     
// DriveDetector - rev. 1 Oct. 31 2007

namespace Dolinay
{
    /// 
    /// Hidden Form which we use to receive Windows messages about flash drives
    /// 

    internal class DetectorForm : Form
    {
        private Label label1;
        private DriveDetector mDetector = null;

        /// 
        /// Set up the hidden form. 
        /// 

        /// DriveDetector object which will receive notification about USB drives see WndProc
        public DetectorForm(DriveDetector detector)
        {
            mDetector = detector;
            this.MinimizeBox = false;
            this.MaximizeBox = false;
            this.ShowInTaskbar = false;
            this.ShowIcon = false;
            this.FormBorderstyle = FormBorderstyle.None;
            this.Load += new System.EventHandler(this.Load_Form);
            this.Activated += new EventHandler(this.Form_Activated);
        }

        private void Load_Form(object sender EventArgs e)
        {
            // We don‘t really need this just to display the label in designer ...
            InitializeComponent();

            // Create really small form invisible anyway.
            this.Size = new System.Drawing.Size(5 5);
        }

        private void Form_Activated(object sender EventArgs e)
        {
            this.Visible = false;
        }

        /// 
        /// This function receives all the windows messages for this window (form).
        /// We call the DriveDetector from here so that is can pick up the messages about
        /// drives arrived and removed.
        /// 

        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (mDetector != null)
            {
                mDetector.WndProc(ref m);
            }
        }

        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(13 30);
            this.label1.Name = “label1“;
            this.label1.Size = new System.Drawing.Size(314 13);
            this.label1.TabIndex = 0;
            this.label1.Text = “This is invisible form. To see DriveDetector code click View Code“;
            // 
            // DetectorForm
            // 
            this.ClientSize = new System.Drawing.Size(360 80);
            this.Controls.Add(this.label1);
            this.Name = “DetectorForm“;
            this.ResumeLayout(false);
            this.PerformLayout();

        }
    }   // class DetectorForm


   

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-03-27 06:33  HID-master\
     文件         378  2017-03-27 06:33  HID-master\.gitattributes
     文件        4884  2017-03-27 06:33  HID-master\.gitignore
     文件        1021  2017-03-27 06:33  HID-master\HID.sln
     目录           0  2017-03-27 06:33  HID-master\HID\
     文件        2550  2017-03-27 06:33  HID-master\HID\ClassDiagram1.cd
     文件       31686  2017-03-27 06:33  HID-master\HID\DriveDetector.cs
     文件       14217  2017-03-27 06:33  HID-master\HID\Form1.Designer.cs
     文件        4014  2017-03-27 06:33  HID-master\HID\Form1.cs
     文件      219062  2017-03-27 06:33  HID-master\HID\Form1.resx
     文件        6743  2017-03-27 06:33  HID-master\HID\HID.csproj
     文件         463  2017-03-27 06:33  HID-master\HID\Program.cs
     目录           0  2017-03-27 06:33  HID-master\HID\Properties\
     文件        1314  2017-03-27 06:33  HID-master\HID\Properties\AssemblyInfo.cs
     文件        2799  2017-03-27 06:33  HID-master\HID\Properties\Resources.Designer.cs
     文件        5496  2017-03-27 06:33  HID-master\HID\Properties\Resources.resx
     文件        1084  2017-03-27 06:33  HID-master\HID\Properties\Settings.Designer.cs
     文件         242  2017-03-27 06:33  HID-master\HID\Properties\Settings.settings
     文件         141  2017-03-27 06:33  HID-master\HID\app.config
     文件       15759  2017-03-27 06:33  HID-master\HID\hid.cs
     文件       28257  2017-03-27 06:33  HID-master\HID\hidAPI.cs
     文件          64  2017-03-27 06:33  HID-master\README.md

评论

共有 条评论