Win32: Shortening Long Paths

 

Using PathCompactPath API, we can short the long strings (Like we see in the title-bar of a Window). Note the API are defined at shlwapi.h and we should link with shlwapi.lib

CString strEditText("C:\\test\\test\\test\\test\\test\\etst.xyz");
PathCompactPath(GetDC()->m_hDC,strEditText.GetBuffer(0),125);
strEditText.ReleaseBuffer();