c# - 显示文件的属性页并导航到选项卡

标签 c# pinvoke

在我的软件中,我需要显示文件的属性对话框并导航到该属性对话框中的特定选项卡吗?请告诉我如何使用 C# 实现此目的?

或者 是否可以用自定义属性对话框替换默认属性对话框?

最佳答案

private bool properties(string Filename) 
{
    SHELLEXECUTEINFO info = new SHELLEXECUTEINFO();
    info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info);
    info.lpVerb = "properties";
    info.lpParameters = "Details";
    info.lpFile = Filename;
    info.nShow = SW_SHOW;
    info.fMask = SEE_MASK_INVOKEIDLIST;
    return ShellExecuteEx(ref info);
}

通过将 info.lpParameters 设置为您希望打开的选项卡的名称,并选择该选项卡。就我而言,“详细信息”...

是的,您需要 codeteq 编写的声明。

这是我使用的声明:

private const int SW_SHOW = 5;
private const uint SEE_MASK_INVOKEIDLIST = 12;

[DllImport("shell32.dll", CharSet = CharSet.Auto)]
static extern bool ShellExecuteEx(ref SHELLEXECUTEINFO lpExecInfo);

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public 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;

关于c# - 显示文件的属性页并导航到选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12213903/

相关文章:

c# - AxAcroPDF吞键,如何让它停止?

c# - 在 C# 中比较两个结构的值

c# - Linq to SQL 存储库应该实现 IDisposable

c# - 多值下拉列表

C# 并行复制 - 小文件问题

c# - 使用 PInvoke 的 CryptoAPI 的 SignerTimeStampEx2

用于导入 .dll 的 C# 包装器, "Attempted to read or write protected memory"

c# - PInvoke 样式传递带有成员动态指针数组的结构

c# - 如何使用 C# 以编程方式在 OpenFile 对话框中选择文件

c# - 如何从 C# 中使用 STARTUPINFOEX 调用 CreateProcess() 并重新设置子进程的父级