MSDN's bug(2): DlgDirListComboBox

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章