Windows Shell扩展dll和Winform进程

时间:2012-04-26 15:28:26

标签: c#-4.0 windows-shell

我按照本教程http://blogs.msdn.com/b/codefx/archive/2010/09/14/writing-windows-shell-extension-with-net-framework-4-c-vb-net-part-1.aspx [^]

为Windows Shell扩展集成了一个dll

现在,我在该dll中添加了一个Windows表单,我正在执行以下操作:

void OnVerbDisplayFileName(IntPtr hWnd)
{
    ShowSelectedFiles form = new ShowSelectedFiles();
    form.Show(selectedFiles);
}

一切正常,只是表单图标没有显示在任务栏中,我找不到运行表单的进程。

有关如何解决此问题的任何提示?也许通过启动一个新流程然后显示表单?

由于

2 个答案:

答案 0 :(得分:0)

尝试使用Form.Show Method (IWin32Window)方法,以便指定所有者窗口。

有关如何从hWnd指定所有者窗口的信息,请参阅http://ryanfarley.com/blog/archive/2004/03/23/465.aspx

还要确保表单的ShowInTaskBar属性为true。

答案 1 :(得分:0)

解决此问题的唯一方法是创建另一个流程。

    void OnVerbDisplayFileName(IntPtr hWnd)
    {
        string file = (new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;
        string executableName = file.Substring(0, file.LastIndexOf("/"));
        executableName += "/MyApp.exe";

        Process gui = new Process();

        gui.StartInfo.FileName = executableName;
        gui.StartInfo.Arguments = selectedFiles.JoinFileNames(" ");

        gui.Start();
    }

干杯!