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