( Index )
Month

Brief Information about the February 2001 CSIG Meeting

D --- Windows 32 Bit Directory Listing in Text Mode

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

Output Sample

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.

D.exe is a text mode Windows 32 bit program. How can you have a Windows text mode program? In the DOS days before Windows, most programs where text mode. 32-bit Windows API text mode programs use the concept of consoles. A console is an interface that provides I/O to character mode applications. This processor independent mechanism makes it easy to port existing character mode applications or to create new character mode tools and applications.

As can be seen in the picture above, this program produces a sorted vertical list of a file names corresponding to a directory listing. The whole thing takes about five pages of programming!

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


SAMPLE CODE
===========
    max = initDisplay(StdOutH);

    getFilenames();     // Make a list of all of the 
						// filenames in this folder.
    i=0;

    do 
        {
        for(x=1,y=0; i<index;    )
            {
		    coord.X=x;
		    coord.Y=y;
		    SetConsoleCursorPosition(StdOutH, coord);

            if (execuitable(array[i]))
                SetConsoleTextAttribute( StdOutH, EXECOLOR);
            else if (linktype(array[i]))
                SetConsoleTextAttribute( StdOutH, LNKCOLOR);
            else
                SetConsoleTextAttribute( StdOutH, TEXTCOLOR);
            pName = formatName(array[i]);
		    WriteConsole(StdOutH, pName, strlen(pName), &count, NULL);
		    ++i; ++y;
		    if (y >= max.Y-3)
			    {
			    y=0; x += COLUMNWIDTH;
                if (x + COLUMNWIDTH - 1 > max.X) break; // screen is full
			    }
	        }
        if (i != index)
            {
            waitKeyboard();
            if (!more) break;
            FillConsoleOutputCharacter(StdOutH,
							' ', max.X*max.Y, org, &count);
            }
        } while (i < index);

    freeFilenames();

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

SOURCE CODE

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