我不太擅长P/Invoke。谁能告诉我如何在.NET中声明和使用下面的shell32.dll函数?
来自http://msdn.microsoft.com/en-us/library/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,
}有人能帮上忙吗?
发布于 2009-08-15 08:53:45
在.NET框架中有一个IDataObject接口和一个DataObject类。
[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();
}
}编辑:我刚刚编译并测试了它,它工作正常(弹出一些带有文件夹外观设置的对话框)。
发布于 2009-10-07 13:53:19
我可能读错了你的问题,但我认为你正在寻找文件的扩展文件属性。例如,打开windows资源管理器并查看属性、所有者、版权、大小、创建日期等列?
Shell32中有一个名为GetDetailsOf的API,它将提供此信息。一篇关于codeproject干杯的开头文章,约翰
https://stackoverflow.com/questions/1281085
复制相似问题