hi everyone

I'm trying to listing files/drives/folders in pc but I couldnt find anything.

please help me ..

--[ cryptacker ]--

7 Years
Discussion Span
Last Post by Ancient Dragon

Here is how to get a list of the drive letters

#include <windows.h>
#include <iostream>

int main()
    char buf[255];
    char cDrive;
    // 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 )
            std::cout << p1 << "\n";
            p1 = p2+1;
        // Oops! something went wrong so display the error message
        DWORD dwError = GetLastError();
        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, dwError, 0, buf, sizeof(buf), 0);
        std::cout << buf << "\n";


For the files that are in the drives you need to use FindFirstFile() and FindNextFile(). Google and you will find examples.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.