automaticDestinations-ms文件和customDestinations-ms有什么区别?它们如何用C#读取和解密?请给出详细代码并指出代码中使用的WindowsAPICodePack库的版本号
.automaticDestinations-ms和.customDestinations-ms是Windows操作系统中用于存储任务栏和开始菜单的快捷方式的文件。它们存储了用户最近使用的应用程序的信息。
.automaticDestinations-ms文件包含了系统自动生成的快捷方式,例如最近打开的文件、访问过的文件夹等。而.customDestinations-ms文件包含了用户自定义的快捷方式,例如用户固定到任务栏或开始菜单的应用程序。
要读取和解密这些文件,可以使用WindowsAPICodePack库。下面是一个示例代码,用于读取和解密.automaticDestinations-ms文件和.customDestinations-ms文件:
using System;
using System.IO;
using Microsoft.WindowsAPICodePack.Shell;
class Program
{
static void Main(string[] args)
{
string automaticDestinationsFile = @"C:\Users\Username\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations\1b4dd67f29cb1962.automaticDestinations-ms";
string customDestinationsFile = @"C:\Users\Username\AppData\Roaming\Microsoft\Windows\Recent\CustomDestinations\1b4dd67f29cb1962.customDestinations-ms";
// 解密.automaticDestinations-ms文件
ShellObject automaticDestinationsShellObject = ShellObject.FromParsingName(automaticDestinationsFile);
PropertyStore automaticDestinationsPropertyStore = automaticDestinationsShellObject.Properties;
ShellProperty automaticDestinationsProperty = automaticDestinationsPropertyStore.GetProperty(SystemProperties.System.Link.TargetUrl);
string automaticDestinationsUrl = automaticDestinationsProperty.ValueAsObject.ToString();
Console.WriteLine("Automatic Destinations URL: " + automaticDestinationsUrl);
// 解密.customDestinations-ms文件
ShellObject customDestinationsShellObject = ShellObject.FromParsingName(customDestinationsFile);
PropertyStore customDestinationsPropertyStore = customDestinationsShellObject.Properties;
ShellProperty customDestinationsProperty = customDestinationsPropertyStore.GetProperty(SystemProperties.System.AppUserModel.ID);
string customDestinationsAppId = customDestinationsProperty.ValueAsObject.ToString();
Console.WriteLine("Custom Destinations App ID: " + customDestinationsAppId);
}
}
上述代码使用的是WindowsAPICodePack库的版本4.1.0。请确保你已经安装了该库,并在项目中引用了正确的版本
原文地址: https://www.cveoy.top/t/topic/infB 著作权归作者所有。请勿转载和采集!