The following is a sample code:
First reference System.Management.dll,
Using system.management;
SELECTQUERY? Query?
=
??????????????????
New
? SelectQuery
"
SELECT? *? From? Win32_logicaldisk? Where? DriveType? =? 3
"
); ???????????? managementObjectsearchSearcher? Searcher?
=
??????????????????
New
? ManagementObjectSearcher (query); ????????????
Foreach
? (ManagementBaseObject? Envvar?
in
? Searcher.get ()) ?????????????
{?????????????????????????? THISLISTBOX1.Items.Add (Envvar ["name"]. TOSTRING ()); ????????????}
If the DriveType in the query statement is 2, it will get a floppy drive. If it is 5, the optical drive will be obtained.