다음을 통해 공유


CListBox::Dir

Adds a list of filenames, drives, or both to a list box.

int Dir(
   UINT attr,
   LPCTSTR lpszWildCard 
);

Parameters

  • attr
    Can be any combination of the enum values described in CFile::GetStatus, or any combination of the following values:

    Value

    Meaning

    0x0000

    File can be read from or written to.

    0x0001

    File can be read from but not written to.

    0x0002

    File is hidden and does not appear in a directory listing.

    0x0004

    File is a system file.

    0x0010

    The name specified by lpszWildCard specifies a directory.

    0x0020

    File has been archived.

    0x4000

    Include all drives that match the name specified by lpszWildCard.

    0x8000

    Exclusive flag. If the exclusive flag is set, only files of the specified type are listed. Otherwise, files of the specified type are listed in addition to "normal" files.

  • lpszWildCard
    Points to a file-specification string. The string can contain wildcards (for example, *.*).

Return Value

The zero-based index of the last filename added to the list. The return value is LB_ERR if an error occurs; the return value is LB_ERRSPACE if insufficient space is available to store the new strings.

Example

// Add all the files and directories in the windows directory.
TCHAR lpszWinPath[MAX_PATH], lpszOldPath[MAX_PATH];
::GetWindowsDirectory(lpszWinPath, MAX_PATH);

::GetCurrentDirectory(MAX_PATH, lpszOldPath);
::SetCurrentDirectory(lpszWinPath);

m_myListBox.ResetContent();
m_myListBox.Dir(DDL_READWRITE|DDL_DIRECTORY, _T("*.*"));

::SetCurrentDirectory(lpszOldPath);

Requirements

Header: afxwin.h

See Also

Reference

CListBox Class

Hierarchy Chart

CWnd::DlgDirList

LB_DIR

CFile::GetStatus

Other Resources

CListBox Members