要显示一个文件的属性页面,浏览到一个标签 [英] To show the properties page of a file and navigate to a tab

查看:217
本文介绍了要显示一个文件的属性页面,浏览到一个标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my software i need to show the property dialog of a file and navigate to a specific tab in that property dialog? please tell me how to acheive this using c#?


是否可以用默认属性对话框替换默认属性对话框?

or Is it possible to replace the default property dialog with a custom one?

推荐答案

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设置为要打开的选项卡的名称该选项卡选中。在我的情况下,详细信息...

By setting info.lpParameters to name of the tab you want it gets opened with that tab selected. In my case "Details"...

是的,需要codeteq写的声明。

Yes you need that declaration that codeteq wrote.

我使用的声明:

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;

}

这篇关于要显示一个文件的属性页面,浏览到一个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆