我不是很好用的P / Invoke。谁能告诉我如何声明和在.NET中使用下面的shell32.dll中的功能?

http://msdn.microsoft。 COM / EN-US /库/ bb762230%28VS.85%29.aspx

HRESULT SHMultiFileProperties(      
    IDataObject *pdtobj,
    DWORD dwFlags
);

它是用于显示在Windows Shell属性对话框为多个文件系统对象。

我已经想出如何使用SHObjectProperties用于一个文件或文件夹:

[DllImport("shell32.dll", SetLastError = true)]
static extern bool SHObjectProperties(uint hwnd, uint shopObjectType, [MarshalAs(UnmanagedType.LPWStr)] string pszObjectName, [MarshalAs(UnmanagedType.LPWStr)] string pszPropertyPage);

public static void ShowDialog(Form parent, FileSystemInfo selected)
{
    SHObjectProperties((uint)parent.Handle, (uint)ObjectType.File, selected.FullName, null));
}

enum ObjectType
{
    Printer = 0x01,
    File = 0x02,
    VoumeGuid = 0x04,
}

谁能帮助?

有帮助吗?

解决方案

这里有一个 IDataObject的接口和一个数据对象在.NET Framework类

[DllImport("shell32.dll", SetLastError = true)]
static extern int SHMultiFileProperties(IDataObject pdtobj, int flags);

public static void Foo()
{
    var pdtobj = new DataObject();

    pdtobj.SetFileDropList(new StringCollection { @"C:\Users", @"C:\Windows" });

    if (SHMultiFileProperties(pdtobj, 0) != 0 /*S_OK*/)
    {
        throw new Win32Exception();
    }
}

编辑:我刚刚编译和测试这和它的作品(弹出一些对话框,文件夹的外观设置)

其他提示

我也许读你的问题正确,但我认为你正在寻找的文件扩展的文件属性。即打开Windows资源管理器和观看喜欢的属性,所有者,版权,大小,创建日期等的列?

有在SHELL32的API调用GetDetailsOf,将提供该信息。在 CodeProject上的起始物品 干杯, 约翰

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top