CFileDialog crashes after calling DoModal on Windows Server 2012 and Windows 8
Below code snippet crashes in windows server 2012. It works fine on Windows 7.
TCHAR ptFiles[2048];
ptFiles[0] =NULL;
TCHAR tcsFilter[] =_T("XYZ Files (*.xyz)|*.xyz|All Files (*.*)|*.*||");
CFileDialog dlg(TRUE,NULL,NULL,
OFN_ALLOWMULTISELECT |OFN_EXPLORER |OFN_FILEMUSTEXIST |
OFN_HIDEREADONLY,
tcsFilter,
NULL);
TCHAR tcsTitle[] =_T("Select XYZ Files to add...");;
dlg.m_ofn.lpstrFile = ptFiles;
dlg.m_ofn.nMaxFile = 2048/(MAX_PATH+1);
dlg.m_ofn.lpstrTitle = tcsTitle;
if (dlg.DoModal()==IDOK) à crash here
{
}
When I collected crash dump, I found that application crashes after calling ‘ApplyOFNToShellDialog()’ at line 'HRESULT hr = (static_cast<IFileDialog*>(m_pIFileDialog))->Show(m_ofn.hwndOwner);' in DoModal() of CFileDialog.
Raman