MSDN's bug(2): DlgDirListComboBox

来源:互联网 发布:单链表是否有环java 编辑:程序博客网 时间:2024/05/13 02:19

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);

原创粉丝点击