資源簡介
C# 檢測USB設備插入 程序十分簡單 注意:程序中用到了一個USB設備的控件,該控件有6個方法,除了識別USB插入 還有檢測USB拔出,接收USB消息等方法。
代碼片段和文件信息
using?System;
using?System.IO;
using?System.Text;
using?System.Runtime.InteropServices;
using?Microsoft.Win32.SafeHandles;
namespace?UsbLibrary
{
#region?Custom?exception
///?
///?Generic?HID?device?exception
///?
????public?class?HIDDeviceException?:?ApplicationException
????{
????????public?HIDDeviceException(string?strMessage)?:?base(strMessage)?{?}
????????public?static?HIDDeviceException?GenerateWithWinError(string?strMessage)
????????{
????????????return?new?HIDDeviceException(string.Format(“Msg:{0}?WinEr:{1:X8}“?strMessage?Marshal.GetLastWin32Error()));
????????}
????????public?static?HIDDeviceException?GenerateError(string?strMessage)
????????{
????????????return?new?HIDDeviceException(string.Format(“Msg:{0}“?strMessage));
??????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-10-10?10:59??USB_test\
?????目錄???????????0??2014-10-10?10:59??USB_test\UsbLibrary\
?????目錄???????????0??2014-10-10?10:59??USB_test\UsbLibrary\bin\
?????目錄???????????0??2014-10-10?10:59??USB_test\UsbLibrary\bin\Debug\
?????文件???????20480??2014-10-10?10:43??USB_test\UsbLibrary\bin\Debug\UsbLibrary.dll
?????文件???????75264??2014-10-10?10:43??USB_test\UsbLibrary\bin\Debug\UsbLibrary.pdb
?????文件???????26505??2014-10-10?10:43??USB_test\UsbLibrary\bin\Debug\UsbLibrary.xm
?????文件???????12810??2007-03-15?14:40??USB_test\UsbLibrary\HIDDevice.cs
?????目錄???????????0??2014-10-10?10:59??USB_test\UsbLibrary\obj\
?????目錄???????????0??2014-10-10?10:59??USB_test\UsbLibrary\obj\Debug\
?????文件????????5903??2014-10-10?11:01??USB_test\UsbLibrary\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????目錄???????????0??2014-10-10?10:59??USB_test\UsbLibrary\obj\Debug\Refactor\
?????文件???????16384??2007-03-08?11:25??USB_test\UsbLibrary\obj\Debug\Refactor\UsbLibrary.dll
?????目錄???????????0??2014-06-24?16:08??USB_test\UsbLibrary\obj\Debug\TempPE\
?????文件?????????813??2014-10-10?10:43??USB_test\UsbLibrary\obj\Debug\UsbLibrary.csproj.FileListAbsolute.txt
?????文件?????????779??2014-10-10?10:43??USB_test\UsbLibrary\obj\Debug\UsbLibrary.csproj.GenerateResource.Cache
?????文件???????20480??2014-10-10?10:43??USB_test\UsbLibrary\obj\Debug\UsbLibrary.dll
?????文件???????75264??2014-10-10?10:43??USB_test\UsbLibrary\obj\Debug\UsbLibrary.pdb
?????文件????????1334??2007-03-09?14:11??USB_test\UsbLibrary\obj\Debug\UsbLibrary.UsbHidBmp.bmp
?????文件?????????180??2014-10-10?10:43??USB_test\UsbLibrary\obj\Debug\UsbLibrary.UsbHidPort.resources
?????文件?????????208??2007-03-15?14:49??USB_test\UsbLibrary\obj\UsbLibrary.csproj.FileList.txt
?????文件????????2396??2010-07-16?15:13??USB_test\UsbLibrary\obj\UsbLibrary.csproj.FileListAbsolute.txt
?????目錄???????????0??2014-10-10?10:59??USB_test\UsbLibrary\Properties\
?????文件????????1391??2007-03-08?10:50??USB_test\UsbLibrary\Properties\AssemblyInfo.cs
?????文件????????2514??2007-03-08?11:31??USB_test\UsbLibrary\Report.cs
?????文件????????2492??2007-03-09?15:35??USB_test\UsbLibrary\SpecifiedDevice.cs
?????文件?????????516??2007-03-08?11:32??USB_test\UsbLibrary\SpecifiedInputReport.cs
?????文件?????????808??2007-03-08?11:32??USB_test\UsbLibrary\SpecifiedOutputReport.cs
?????文件????????1334??2007-03-09?14:11??USB_test\UsbLibrary\UsbHidBmp.bmp
?????文件???????10185??2009-12-29?16:18??USB_test\UsbLibrary\UsbHidPort.cs
?????文件????????1096??2009-12-29?16:18??USB_test\UsbLibrary\UsbHidPort.Designer.cs
............此處省略44個文件信息
評論
共有 條評論