Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / multimedia / video

Enumerating supported media files

5.00/5 (1 vote)
16 Apr 2010CPOL 1  
Ever had to enumerate the supported media files under Windows for example for the filter-string for GetOpenFileName?Here is a simple solution (using ATL for the registry access):void EnumSupportedMediaFileTypes(){ CRegKey key; CString s; DWORD dwLen; DWORD dw =...
Ever had to enumerate the supported media files under Windows for example for the filter-string for GetOpenFileName?

Here is a simple solution (using ATL for the registry access):

void EnumSupportedMediaFileTypes()
{
  CRegKey key;

  CString s;
  DWORD dwLen;
  DWORD dw = key.Open(HKEY_CLASSES_ROOT, _T("Media Type\\Extensions"), KEY_READ);
  for(DWORD n = 0;dw == ERROR_SUCCESS; n++)
  {
    dwLen = 100;
    dw = key.EnumKey(n, s.GetBuffer(dwLen), &dwLen);
    s.ReleaseBuffer();
    if (ERROR_SUCCESS == dw)
    {
      // do something with the file extension here
    }
  }
}


This might not include all supported types, but it is a good beginning... :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)