Click here to Skip to main content
15,913,685 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Default Windows color list ? Pin
Maximilien24-Apr-03 9:06
Maximilien24-Apr-03 9:06 
GeneralRe: Default Windows color list ? Pin
David Crow24-Apr-03 10:20
David Crow24-Apr-03 10:20 
GeneralRe: Default Windows color list ? Pin
Maximilien24-Apr-03 17:38
Maximilien24-Apr-03 17:38 
AnswerRe: Default Windows color list ? Pin
Roger Allen25-Apr-03 2:07
Roger Allen25-Apr-03 2:07 
GeneralGetting the Display Name of a file Extension Pin
Diarrhio24-Apr-03 7:05
Diarrhio24-Apr-03 7:05 
GeneralRe: Getting the Display Name of a file Extension Pin
Shog924-Apr-03 7:47
sitebuilderShog924-Apr-03 7:47 
GeneralRe: Getting the Display Name of a file Extension Pin
Diarrhio24-Apr-03 7:53
Diarrhio24-Apr-03 7:53 
GeneralRe: Getting the Display Name of a file Extension Pin
David Crow24-Apr-03 8:31
David Crow24-Apr-03 8:31 
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);
    }
}

GeneralADO related question Pin
Shah Shehpori24-Apr-03 6:24
sussShah Shehpori24-Apr-03 6:24 
GeneralRe: ADO related question Pin
Giles24-Apr-03 6:42
Giles24-Apr-03 6:42 
GeneralRe: ADO related question Pin
fat88824-Apr-03 17:32
fat88824-Apr-03 17:32 
GeneralIntegrating a .HLP help file into a VC++ project Pin
Colin Davidson24-Apr-03 6:22
Colin Davidson24-Apr-03 6:22 
GeneralRe: Integrating a .HLP help file into a VC++ project Pin
Roger Allen24-Apr-03 6:59
Roger Allen24-Apr-03 6:59 
GeneralRe: Integrating a .HLP help file into a VC++ project Pin
Toni7825-Apr-03 7:49
Toni7825-Apr-03 7:49 
GeneralVisual C++ .Net 2003 Standard edition Pin
Darren Steadman24-Apr-03 5:54
Darren Steadman24-Apr-03 5:54 
GeneralProcess enumeration problems Pin
Zamfir24-Apr-03 5:46
Zamfir24-Apr-03 5:46 
GeneralWebBrowser Question Pin
Brian van der Beek24-Apr-03 5:40
Brian van der Beek24-Apr-03 5:40 
GeneralRe: WebBrowser Question Pin
Chris Losinger24-Apr-03 5:50
professionalChris Losinger24-Apr-03 5:50 
GeneralRe: WebBrowser Question Pin
Chris Richardson24-Apr-03 6:38
Chris Richardson24-Apr-03 6:38 
GeneralRe: WebBrowser Question Pin
Joan M24-Apr-03 6:52
professionalJoan M24-Apr-03 6:52 
GeneralRe: WebBrowser Question Pin
Brian van der Beek24-Apr-03 20:56
Brian van der Beek24-Apr-03 20:56 
QuestionHow to disable frame resize Pin
Anonymous24-Apr-03 5:37
Anonymous24-Apr-03 5:37 
AnswerRe: How to disable frame resize Pin
Joan M24-Apr-03 7:04
professionalJoan M24-Apr-03 7:04 
AnswerRe: How to disable frame resize Pin
Phil Hamer24-Apr-03 13:31
Phil Hamer24-Apr-03 13:31 
GeneralI do not want to wait for an event Pin
--dlb--24-Apr-03 5:02
--dlb--24-Apr-03 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.