Bra*_*ith 5 c# mediacenter windows-7
我正在为Media Center(Windows 7附带的版本)编写一个加载项,并希望检索用户已包含在媒体库中的物理目录列表(图片,视频,录制的电视,电影,音乐) .
Media Center对象模型(Microsoft.MediaCenter.*)似乎没有任何规定来获取此信息.
注册表有一个键HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Media Center\MediaFolders,但这些键总是空的.
似乎有一个完整的目录列表%userprofile%\AppData\Local\Microsoft\Media Player\wmpfolders.wmdb,但没有办法分辨每个目录与哪个媒体库有关,因为这些是Media Player的设置,它们的存在可能只是巧合.
有谁知道如何可靠地检索这些目录的列表,最好是从加载项程序集中(即使用C#)?
我使用 Reflector 来了解 ehshell 是如何做到这一点的。对于图片、视频、音乐和录制的电视,它使用从 ehuihlp.dll 导入的方法。对于电影,它只是直接从 中提取列表HKCR\Software\Microsoft\Windows\CurrentVersion\Media Center\MediaFolders\Movie。
以下是如何使用导入方法的示例:
using System.Runtime.InteropServices;
...
[DllImport(@"c:\Windows\ehome\ehuihlp.dll", CharSet = CharSet.Unicode)]
static extern int EhGetLocationsForLibrary(ref Guid knownFolderGuid, [MarshalAs(UnmanagedType.SafeArray)] out string[] locations);
Run Code Online (Sandbox Code Playgroud)
...
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")
Run Code Online (Sandbox Code Playgroud)
...
string[] locations;
EhGetLocationsForLibrary(ref PicturesLibrary, out locations);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1306 次 |
| 最近记录: |