在自己界面添加一组合框控件,关联 CComboBox m_ctrlComboBox;
就可以调用下面代码获取指定目录的全部文件了。
m_ctrlComboBox.Dir(DDL_DIRECTORY , _T("c:\\*.*")); //在组合框中显示文件列表
Dir为组合框类的成员函数,主要用于添加文件列表,或磁盘驱动名到组合框中。
此函数的更多介绍可以查阅手册 。
如下
int Dir( UINT attr, LPCTSTR lpszWildCard );
Return Value
If the return value is greater than or equal to 0, it is the zero-based index of the last filename added to the list. The return value is CB_ERR if an error occurs; the return value is CB_ERRSPACE if insufficient space is available to store the new strings.
Parameters
attr
Can be any combination of the enum values described in CFile::GetStatus or any combination of the following values:
DDL_READWRITE File can be read from or written to.
DDL_READONLY File can be read from but not written to.
DDL_HIDDEN File is hidden and does not appear in a directory listing.
DDL_SYSTEM File is a system file.
DDL_DIRECTORY The name specified by lpszWildCard specifies a directory.
DDL_ARCHIVE File has been archived.
DDL_DRIVES Include all drives that match the name specified by lpszWildCard.
DDL_EXCLUSIVE 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, *.*).
Remarks
Adds a list of filenames and/or drives to the list box of a combo box.
|