载入中,请稍候……

C# 监控U盘插入与拔出

Admin 于 2008-09-24 13:31:10 发表.NET

  1. using System; 
  2. using System.Collections.Generic; 
  3. using System.ComponentModel; 
  4. using System.Data; 
  5. using System.Drawing; 
  6. using System.Text; 
  7. using System.Windows.Forms; 
  8. using System.Runtime.InteropServices; 
  9.  
  10. namespace upan 
  11.     public partial class Form1 : Form 
  12.     { 
  13.         public Form1() 
  14.         { 
  15.             InitializeComponent(); 
  16.         } 
  17.         public Message mm; 
  18.         protected override void WndProc(ref Message m) //监视Windows消息 
  19.         { 
  20.             const int WM_DEVICECHANGE = 0x219; 
  21.             const int WM_DEVICEARRVIAL = 0x8000;//如果m.Msg的值为0x8000那么表示有U盘插入 
  22.             const int WM_DEVICEMOVECOMPLETE = 0x8004; 
  23.             switch (m.Msg) 
  24.             { 
  25.                 case WM_DEVICECHANGE: 
  26.                     { 
  27.                         ShowDeviceChanged("WM_DEVICECHANGE"); 
  28.                         if (m.WParam.ToInt32() == WM_DEVICEARRVIAL) 
  29.                             ShowDeviceChanged("WM_DEVICEARRVIAL"); 
  30.                         else if (m.WParam.ToInt32() == WM_DEVICEMOVECOMPLETE) 
  31.                             ShowDeviceChanged("WM_DEVICEMOVECOMPLETE"); 
  32.                     } 
  33.                     break
  34.             } 
  35.             base.WndProc(ref m); //将系统消息传递自父类的WndProc 
  36.  
  37.         } 
  38.         public void ShowDeviceChanged(string message) 
  39.         { 
  40.             switch (message) 
  41.             { 
  42.                 case "WM_DEVICECHANGE"
  43.                     this.textBox_Message.Text += "Device Changed \r\n"
  44.                     break
  45.                 case "WM_DEVICEMOVECOMPLETE"
  46.                     this.textBox_Message.Text += "Device Moved\r\n"
  47.                     break
  48.                 case "WM_DEVICEARRVIAL"
  49.                     this.textBox_Message.Text += "Device Arrived\r\n"
  50.                     break
  51.             } 
  52.         } 
  53.  
  54.         private void Form1_Load(object sender, EventArgs e) 
  55.         { 
  56.             WndProc(ref mm); 
  57.         } 
  58.     } 
被阅983次, 0票U盘 发表评论

c++监控u盘插入拔出

Admin 于 2008-08-25 06:27:02 发表C/C++

被阅518次, 0票U盘 发表评论

U盘小偷c++源码

Admin 于 2008-08-25 06:23:31 发表C/C++

/*USBsniffer*/

功能简介:

本程序以3秒为周期,自动检测本地磁盘改动信息,如果发现有移动硬盘或者U盘等USB存储设备后,会主动窃取其中所有信息,并保存在用户指定路
 

被阅708次, 0票U盘 发表评论
1 / 1 / 3 | « 1 » |

Powered by MiniBoke v2.0.0.8 Build 0828

Copyright © 2008 迷你博客. All rights reserved.

粤ICP备07500939号