Did you not read all of the documentation? It states: If the uFlags parameter includes the SHGFI_USEFILEATTRIBUTES flag, this parameter does not have to be a valid file name. The function proceeds as if the file exists with the specified name and with the file attributes passed in the dwFileAttributes parameter. This enables you to obtain information about a file type by passing just the extension for pszPath and passing FILE_ATTRIBUTE_NORMAL in dwFileAttributes. That implies that this will work:
SHFILEINFO fi;
CString strExtension;
m\_ebExtension.GetWindowText(strExtension);
if (SHGetFileInfo(strExtension, FILE\_ATTRIBUTE\_NORMAL, &fi, sizeof(fi), SHGFI\_USEFILEATTRIBUTES | SHGFI\_TYPENAME) != 0)
{
m\_staticAssocApp.SetWindowText(fi.szTypeName);
}
If you still do not want to use SHGetFileInfo(), try this. It's from the top of my head so you may have to tweak it:
HKEY hKey;
CString strExtension;
TCHAR szValue\[128\];
LONG lSize;
m\_ebExtension.GetWindowText(strExtension);
if (RegOpenKey(HKEY\_CLASSES\_ROOT, strExtension, &hKey) == ERROR\_SUCCESS)
{
lSize = sizeof(szValue);
RegQueryValue(hKey, \_T(""), szValue, &lSize);
RegCloseKey(hKey);
if (RegOpenKey(HKEY\_CLASSES\_ROOT, szValue, &hKey) == ERROR\_SUCCESS)
{
lSize = sizeof(szValue);
RegQueryValue(hKey, \_T(""), szValue, &lSize);
RegCloseKey(hKey);
m\_staticAssocApp.SetWindowText(szValue);
}
}