1 | #include <Windows.h>
|
---|
2 | #include <stdio.h>
|
---|
3 | #include <TCHAR.h>
|
---|
4 |
|
---|
5 | int main(int argc, char* argv[])
|
---|
6 | {
|
---|
7 | int len = GetLogicalDriveStrings(0, 0);
|
---|
8 |
|
---|
9 | TCHAR *lpBuffer = (TCHAR *)malloc((len+1)*sizeof(TCHAR));
|
---|
10 | if (!GetLogicalDriveStrings(len, lpBuffer))
|
---|
11 | {
|
---|
12 | _tprintf(_T("Call to GetLogicalDriveStrings failed.\n"));
|
---|
13 | }
|
---|
14 | else
|
---|
15 | {
|
---|
16 | // Iterate over strings in buffer
|
---|
17 | TCHAR *pDrive = lpBuffer;
|
---|
18 | while (*pDrive)
|
---|
19 | {
|
---|
20 | _tprintf(_T("%s\n"), pDrive);
|
---|
21 |
|
---|
22 | size_t driveLen = _tcslen(pDrive);
|
---|
23 | // Drive + null char
|
---|
24 | pDrive += driveLen + 1;
|
---|
25 | }
|
---|
26 | }
|
---|
27 |
|
---|
28 | free(lpBuffer);
|
---|
29 |
|
---|
30 | return 0;
|
---|
31 | }
|
---|