小编g.l*_*sch的帖子

C# WindowsApiCodepack PropertySystem AccessViolationException

使用 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)

c# windows-api-code-pack

5
推荐指数
1
解决办法
1829
查看次数

标签 统计

c# ×1

windows-api-code-pack ×1