I'm writing an add-in for Media Center (the version that comes with Windows 7) and want to retrieve the list of physical directories which the user has included in the media libraries (pictures, videos, recorded tv, movies, music).
The Media Center object model (Microsoft.MediaCenter.*
) does not seem to have any provision to get this information.
The registry has a key at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Media Center\MediaFolders
, however these are always empty.
There appears to be a complete list of the directories in %userprofile%\AppData\Local\Microsoft\Media Player\wmpfolders.wmdb
, but there's no way to tell which media library each directory relates to and, since these are the settings for Media Player, their presence may just be coincidental.
Does anyone know how to reliably retrieve a list of these directories, preferably from within the add-in assembly (i.e. using C#)?
I used Reflector to take a peak at how ehshell does this. For Pictures, Videos, Music, and Recorded TV it's using an imported method from ehuihlp.dll. For Movies it just pulls the list directly from
HKCR\Software\Microsoft\Windows\CurrentVersion\Media Center\MediaFolders\Movie
.Here's an example of how to use the imported method:
using System.Runtime.InteropServices
;...
...
...