Click here to Skip to main content
Click here to Skip to main content

Enumerating supported media files

, 16 Apr 2010
Rate this:
Please Sign up or sign in to vote.
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... Smile | :)

License

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

About the Author

imagiro
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 --
| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 16 Apr 2010
Article Copyright 2010 by imagiro
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid