【发布时间】:2016-04-27 07:59:36
【问题描述】:
我使用了here 中提到的方法,像在 windows 中一样显示文件属性。
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
struct SHELLEXECUTEINFO
{
public int cbSize;
public uint fMask;
public IntPtr hwnd;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpVerb;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpFile;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpParameters;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpDirectory;
public int nShow;
public IntPtr hInstApp;
public IntPtr lpIDList;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpClass;
public IntPtr hkeyClass;
public uint dwHotKey;
public IntPtr hIcon;
public IntPtr hProcess;
}
public static bool ShowFileProperties(string Filename)
{
SHELLEXECUTEINFO info = new SHELLEXECUTEINFO();
info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info);
info.lpVerb = "properties";
info.lpFile = Filename;
info.nShow = SW_SHOW;
info.fMask = SEE_MASK_INVOKEIDLIST;
return ShellExecuteEx(ref info);
}
我想知道是否有办法在选择多个文件时显示属性。
显示“多个文件的属性”,我的意思是当用户按住 ctrl 并选择多个文件时,右键单击-> 属性。链接中提到的代码适用于单个文件。但我需要显示多个文件。知道怎么做吗?
【问题讨论】:
-
因此,如果您为一个文件手动执行此操作,您将获得一个正确的属性窗口。. 对 2 个文件执行相同操作,您将获得一个属性窗口而不是两个.. 所以我认为您必须写你自己的..
-
@3not3 我更新了我原来的解决方案。请让我知道它是否适合您。
-
正是我想要的,我接受它作为答案。荣誉:)