removable

C# how to know if removable disk is a usb drive, or a sd card?

孤人 提交于 2019-12-21 07:27:21
问题 Windows 7 platform, C# I use the following statement to list all drives: DriveInfo[] drives = DriveInfo.GetDrives(); then I can use DriveType to find out all those removable disks: foreach (var drive in drives) { if(drive.DriveType == DriveType.Removable) yield return drive; } now my problem is, SD-card disk and USB flashdisk shared same driveType: Removable, so how can i only find USB flashdisk out? thanks! 回答1: You can take advantage of ManagementObjectSearcher using it to query the disk

How to find the unique serial number of a flash device?

安稳与你 提交于 2019-11-27 15:22:51
问题 I've found several snippets and .pas files that can detect when USB flash drives are inserted and removed. Some give all kind of good information, however what I need is the devices' unique serial number, not the volumes' serial number. My current .pas file (which I don't remember where I found) also seems to detect SD cards (which I like). If you want a look, you can find it here (it only returns the drive number and inserted/removed): unit UsbDetector; interface uses Classes; type