获取Windows Media Center库中包含的目录
我正在为Media Center(Windows 7附带的版本)编写一个加载项,并希望检索用户已包含在媒体库中的物理目录列表(图片,video,录制的电视,电影,音乐) 。
Media Center对象模型( Microsoft.MediaCenter.*
)似乎没有任何规定来获取此信息。
注册表在HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionMedia CenterMediaFolders
有一个键,但这些键始终为空。
在%userprofile%AppDataLocalMicrosoftMedia Playerwmpfolders.wmdb
似乎有完整的目录列表,但无法分辨每个目录与哪个媒体库相关,因为这些是Media的设置玩家,他们的存在可能只是巧合。
有谁知道如何可靠地检索这些目录的列表,最好是从加载项程序集中(即使用C#)?
我使用Reflector在ehshell如何做到这一点上达到顶峰。 对于图片,video,音乐和录制的电视,它使用的是ehuihlp.dll的导入方法。 对于电影,它只是直接从HKCRSoftwareMicrosoftWindowsCurrentVersionMedia CenterMediaFoldersMovie
提取列表。
以下是如何使用导入方法的示例:
using System.Runtime.InteropServices
;
…
[DllImport(@"c:Windowsehomeehuihlp.dll", CharSet = CharSet.Unicode)] static extern int EhGetLocationsForLibrary(ref Guid knownFolderGuid, [MarshalAs(UnmanagedType.SafeArray)] out string[] locations);
…
Guid RecordedTVLibrary = new Guid("1a6fdba2-f42d-4358-a798-b74d745926c5"); Guid MusicLibrary = new Guid("2112ab0a-c86a-4ffe-a368-0de96e47012e"); Guid PicturesLibrary = new Guid("a990ae9f-a03b-4e80-94bc-9912d7504104"); Guid VideosLibrary = new Guid("491e922f-5643-4af4-a7eb-4e7a138d8174")
…
string[] locations; EhGetLocationsForLibrary(ref PicturesLibrary, out locations);
private void ListItems(ListMakerItem listMakerItem) { if (listMakerItem.MediaTypes == Microsoft.MediaCenter.ListMaker.MediaTypes.Folder) { // Recurse into Folders ListMakerList lml = listMakerItem.Children; foreach (ListMakerItem listMakerChildItem in lml) { ListItems(listMakerChildItem); } } else { BuildDirectoryList(listMakerItem.FileName) } } private void BuildDirectoryList(string fileName) { // Parse fileName and build unique directory list }
这是一种间接方式,但可以使您构建所需的目录列表。 有关详细信息,请参阅https://msdn.microsoft.com/en-us/library/ee525804.aspx 。
上述就是C#学习教程:获取Windows Media Center库中包含的目录分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/998450.html