Click here to Skip to main content
15,867,568 members
Articles / Multimedia / Video
Tip/Trick

Enumerating supported media files

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
16 Apr 2010CPOL 6.6K   4  
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)


Written By
Software Developer
Germany Germany
Born in 1968 I do programming since over 25 years now. I started with Basic on a ZX81 and with hacking hexcodes in a Microprofessor before I switched to C++ and other languages.

Since more than 10 years I work as a professional software developer, currently for Salsitasoft in Prague.

Comments and Discussions

 
-- There are no messages in this forum --