int DlgDirListComboBox( LPTSTR lpPathSpec, int nIDComboBox, int nIDStaticPath, UINT nFileType );
Example
// If pDialog points to a CDialog object with a combo box
// with the identifier IDC_DIRBOX, this call will populate
// the box with only the non-hidden subdirectories in the root
// directory of the C:/ drive.
pDialog->DlgDirListComboBox(_T("C://"), IDC_DIRBOX, 0,
DDL_EXCLUSIVE | DDL_DIRECTORY);
would cause crash, becase
lpPathSpec
Points to a null-terminated string that contains the path or filename. DlgDirListComboBox modifies this string, which should be long enough to contain the modifications.
Correct Usage
TCHAR szPath [MAX_PATH] = _T("C://") ;
pDialog->DlgDirListComboBox(szPath, IDC_DIRBOX, 0,
DDL_EXCLUSIVE | DDL_DIRECTORY);
博客介绍了DlgDirListComboBox函数,指出示例代码会导致崩溃,原因是该函数会修改传入的字符串,此字符串需足够长。还给出了正确用法,使用TCHAR数组存储路径并传入函数。
337

被折叠的 条评论
为什么被折叠?



