使用 WindowsAPICodePack 在 Win8/64 位上执行一些资源管理器/shell 操作。使用 x64 平台目标迭代文件属性时,属性系统存在一些问题,导致 AccessViolationException。PropVariant.cs 似乎存在一些问题。切换到 x86 可以解决问题,但会导致目录列表不完整(system32/drivers 中缺少 fe“etc”)。有任何想法吗?
using System;
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
namespace ApiCodepackTest
{
class Program
{
const string path = @"c:\windows\system32\drivers";
static void Main(string[] args)
{
var shellObject = (ShellFolder)ShellObject.FromParsingName(path);
showProperties(shellObject);
showItems(shellObject);
Console.ReadLine();
}
static void showProperties(ShellFolder folder)
{
var sys = folder.Properties.System;
foreach (var prop in sys.GetType().GetProperties())
{
try
{
var shellProperty = prop.GetValue(sys) as IShellProperty;
if (shellProperty != null && shellProperty.ValueAsObject != null)
Console.WriteLine(shellProperty.CanonicalName + " " + …Run Code Online (Sandbox Code Playgroud)