#include <windows.h>
#include <stdio.h>


int main()
{
    char buf[255];
    // get the drive letters as a set of strings
    int sz = GetLogicalDriveStrings(sizeof(buf), buf);
    if( sz > 0)
    {
        // buf now contains a list of all the drive letters.  Each drive letter is
        // terminated with '\0' and the last one is terminated by two consecutive '\0' bytes.
        char* p1 = buf;
        char* p2;
        while( *p1 != '\0' && (p2 = strchr(p1,'\0')) != NULL )
        {
            printf("%s\n", p1);
            p1 = p2+1;
        }
    }
    else
    {
        // Oops! something went wrong so display the error message
        DWORD dwError = GetLastError();
        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, dwError, 0, buf, sizeof(buf), 0);
        printf("%s\n", buf);

    }
}
3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
-3

See rather the Microsoft sample.
16 years old... (beginner code for a so simple api, posted 10000 times on BBS & Usenet...)

Edited by marco93: n/a

Votes + Comments
You're pathetic.
2

>>See rather the Microsoft sample
What sample? Post link.

[edit] Probably this?

>>posted 10000 times on BBS & Usenet.
Probably -- now its been posted 10001 times :)

Edited by Ancient Dragon: n/a

Votes + Comments
Well said.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.