C 監控U盤插入與拔出

2021-06-02 20:08:59 字數 576 閱讀 8112

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.text;

using system.windows.forms;

using system.runtime.interopservices;

public partial class usbform2 : form

public message mm;

protected override void wndproc(ref message m) //監視windows訊息

break;

}base.wndproc(ref m); //將系統訊息傳遞自父類的wndproc

}public void showdevicechanged(string message)

}private void form1_load(object sender, eventargs e)}}

U盤插入與拔出識別

在很多應用程式中,我們往往希望程式能夠自動檢測出即插即用型裝置的插入和拔出.在windows平台上,當pnp裝置插入或柭出時系統會發出wm devicechange訊息,應用程式只需截獲該訊息並作出相應的處理,就可以實現上述功能.下面我們以乙個mfc開發環境,寫出乙個能夠識別出u盤插入和拔出的程式例...

C WPF 檢測U盤插入,拔出。

using system using system.collections.generic using system.io using system.linq using system.runtime.interopservices using system.text using system.th...

Delphi自動檢測U盤插入 拔出及獲取U盤碟符

unit unit1 inte ce uses windows,messages,sysutils,variants,classes,graphics,controls,forms,type tform1 class tform procedure button1click sender tobje...