【问题标题】:Windows Shell Extension dll and Winform processWindows Shell 扩展 dll 和 Winform 进程
【发布时间】:2012-04-26 15:28:26
【问题描述】:

按照本教程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);
}

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

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

谢谢

【问题讨论】:

    标签: c#-4.0 windows-shell


    【解决方案1】:

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

    请参阅http://ryanfarley.com/blog/archive/2004/03/23/465.aspx 了解如何从 hWnd 指定所有者窗口。

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

    【讨论】:

    • 我试过了,但在这种情况下它不起作用。请参阅我提出的解决方案。不过,谢谢!
    【解决方案2】:

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

        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();
        }
    

    干杯!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-20
      • 2011-08-08
      • 2011-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-10
      • 1970-01-01
      相关资源
      最近更新 更多