You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Windows-API-examples/system/get_drives.c

26 lines
536 B

#include <windows.h>
#include <wchar.h>
int wmain(void) {
wchar_t LogicalDrives[MAX_PATH] = {0};
DWORD r = GetLogicalDriveStringsW(MAX_PATH, LogicalDrives);
if (r == 0) {
wprintf(L"Failed to get drive names %ld", GetLastError());
return 1;
}
if (r > 0 && r <= MAX_PATH) {
wchar_t *SingleDrive = LogicalDrives;
while(*SingleDrive) {
wprintf(L"%ls\n", SingleDrive);
SingleDrive += wcslen(SingleDrive) + 1;
}
}
return 0;
}