mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2024-11-24 11:25:30 +00:00
Create get_drives.c
This commit is contained in:
parent
74778c8a35
commit
57a2578aba
26
system/get_drives.c
Normal file
26
system/get_drives.c
Normal file
@ -0,0 +1,26 @@
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user