( Index )

Brief Information about the December 2001 CSIG Meeting

FILES.EXE - The Utility That Microsoft Forgot!

3rd Tuesday of the month. 7:30PM - C/C++ Group, SPRS

Welcome to the C++ Users Group. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

Sample Output

Sample Output The object of this month's program is display and optionally print a list of files in a folder or directory. Think about it. It seems like the simplest task in the world. You have Explorer open and you're looking at the files. Now you want a hard copy printout of the directory. Here are the Microsoft options: a) Bring up a command box and type a DOS command redirected to the printer. (Difficult if it's a network printer.) b) Do an Alt-PrintScreen and paste the partial directory information into Microsoft Paint.

This month's program uses an MFC Class CLISTCTRL to display the files and some API functions to choose the folder and then print the results. As can be seen from the figure, even large folders such as the Windows System32 directory can be printed. (Note that it is over 29 pages!)

This program will demonstrate some of the inner workings of a dialog based Windows program with the MFC layer. It works under Windows 95, 98, 98se, ME, NT, 2000, and XP.

At the meeting on Tuesday night we will be discussing the utility and the source code.

int CFDlg::DoFillFiles(char *path, CListCtrl *pLC)
    WIN32_FIND_DATA FindFileData;
    HANDLE hFind;
    SYSTEMTIME FileTime;
    char info[_MAX_PATH+50];    BOOL result;

    hFind=FindFirstFile(path, &FindFileData);

    if (hFind == INVALID_HANDLE_VALUE) result = false; else result = true;
    while (result)
        int item;   BOOL code;
        if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
            strcpy(info, FindFileData.cFileName);
            item = pLC->GetItemCount();
            item = pLC->InsertItem(LVIF_TEXT+LVIF_PARAM, 
                            item, info, 0, 0, 0, item);

            FileTimeToSystemTime(&FindFileData.ftLastWriteTime, &FileTime);
            wsprintf(info, "%04d-%02d-%02d   %02d:%02d:%02d",
            code=pLC->SetItem(item, 1, LVIF_TEXT, info, 0, 0, 0, 0);

            wsprintf(info, "%ld", FindFileData.nFileSizeLow);
            code=pLC->SetItem(item, 2, LVIF_TEXT, info, 0, 0, 0, 0);
        result=FindNextFile(hFind, &FindFileData);
    // pLC->RedrawItems(0, pLC->GetItemCount()-1);
    return 0;

"Random Access" questions start at 7:30 Tuesday night.


Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page