Article ID: 148806
Article Last Modified on 11/21/2006
/* Compile options needed: Default MFC applications.
*/
void CLongFileNameApp::EnableShellOpen()
{
ASSERT(m_atomApp == NULL && m_atomSystemTopic == NULL); // do once
CString strShortName;
TCHAR szLongPathName[_MAX_PATH];
::GetModuleFileName(m_hInstance, szLongPathName, _MAX_PATH);
if (::GetShortPathName(szLongPathName,
strShortName.GetBuffer(_MAX_PATH), _MAX_PATH) == 0)
{
// Rare failure case (especially on not-so-modern file systems)
strShortName = szLongPathName;
}
strShortName.ReleaseBuffer();
int nPos = strShortName.ReverseFind('\\');
if (nPos != -1)
strShortName = strShortName.Right(strShortName.GetLength()- nPos-1);
nPos = strShortName.ReverseFind('.');
if (nPos != -1)
strShortName = strShortName.Left(nPos);
m_atomApp = ::GlobalAddAtom(strShortName);
m_atomSystemTopic = ::GlobalAddAtom(_T("system"));
}Additional query words: 8.3 filename EnableShellOpen
Keywords: kbbug kbcode kbfix kbnoupdate KB148806