1 using System;
2 using System.Collections;
3 using System.Windows.API;
4
5 namespace FileExplorer
6 {
7 public List<string> GetLogicalDrives()
8 {
9 List<string> logicalDriveStrings;
10 int logicalDrives = WinGetLogicalDrives();
11 if (logicalDrives == 0)
12 {
13 throw WindowsAPIException(WinGetLastError());
14 }
15 for (int i = 0; i < 16; ++i;)
16 {
17 int drive = 1 << i;
18 if ((logicalDrives & drive) != 0)
19 {
20 logicalDriveStrings.Add(string(cast<char>(cast<int>('A') + i)).Append(':'));
21 }
22 }
23 return logicalDriveStrings;
24 }
25 }