help me please!

hey ho
someone please help me:
i need a little C program, that prints all the directories name!
it will get a hard disk char (c, d, etc.) and print all the dirs name in it.
TNX!

Comments

  • : hey ho
    : someone please help me:
    : i need a little C program, that prints all the directories name!
    : it will get a hard disk char (c, d, etc.) and print all the dirs name in it.

    GetLogicalDrives() is a WinAPI function that will retrieve the available drives in a bitmask.
  • : GetLogicalDrives() is a WinAPI function that will retrieve the available drives in a bitmask.

    Im new to suchs things... How do I get started? I mean... How do I acess WinApi functions?
    And a second doubt... what means API?
    Thanks for future help...
  • : hey ho
    : someone please help me:
    : i need a little C program, that prints all the directories name!
    : it will get a hard disk char (c, d, etc.) and print all the dirs name in it.
    : TNX!
    :

    Here you go: ;-)

    [code]
    #include
    #include
    #include

    int _tmain(int argc, TCHAR *argv[])
    {
    if (argc > 1) {
    WIN32_FIND_DATA fd;
    TCHAR filename[MAX_PATH];

    _stprintf(filename, _T("%c:\*.*"), *argv[1]);

    if (HANDLE hFind = FindFirstFile(filename, &fd)) {

    do {
    if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
    _putts(fd.cFileName);
    } while (FindNextFile(hFind, &fd));

    FindClose(hFind);
    }
    } else {
    _ftprintf(stderr, _T("Usage: %s [drive_letter]"), argv[0]);
    }

    return 0;
    }
    [/code]
  • Yes!! Thanks a lot! If you put some comments it will be perfect, but anyway... excellent!
  • : Yes!! Thanks a lot! If you put some comments it will be perfect, but anyway... excellent!
    :

    Glad it works as wanted; as for the comments... a 10-line function doesn't need any of these... just kidding :))
    Anyway, the only 'esoteric' parts in the program are the functions FindFirstFile() and FindNextFile() - you'll find more info on them by consulting the MSDN or the Win32 SDK help
  • : Glad it works as wanted; as for the comments... a 10-line function doesn't need any of these... just kidding :))
    : Anyway, the only 'esoteric' parts in the program are the functions FindFirstFile() and FindNextFile() - you'll find more info on them by consulting the MSDN or the Win32 SDK help

    Ok! :-) I'll read about as soon as I have time... I have so many things to learn... right now I'm studing graphical mode using VGA... *going crazy*. Thanks!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories