繁体   English   中英

.NET WPF Process.Start()在Vista和Windows 7上不起作用

[英].NET WPF Process.Start() not working on Vista and Windows 7

我有WPF应用程序。 在Windows7上测试我的应用程序后,意识到打开帮助不起作用。

基本上打开chm帮助文件,我称之为:

Process.Start("help.chm");

没有任何反应。 我也在Vista SP1上尝试过我的应用程序,结果相同。 我是两个OS的管理员

我已经用谷歌搜索了这个问题,但是还没有找到解决方案。

有办法解决这个问题吗?

您是否经历过此类不兼容问题。

谢谢!

您是否尝试过ShellExecute?

使用System.Runtime.InteropServices;

[DllImport(“ shell32.dll”,CharSet = CharSet.Auto)]静态外部ShellShellExecuteEx(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;
}

您可以尝试使用以下步骤开始流程:

        SHELLEXECUTEINFO info = new SHELLEXECUTEINFO();
        info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info);
        info.lpVerb = "open";
        info.lpFile = "help.chm";
        info.nShow = 5;
        info.fMask = 12;

        ShellExecuteEx(ref info);

http://www.pinvoke.net/default.aspx/shell32.ShellExecuteEx

SO线程应为您提供帮助。 另外,这是有关UAC以及如何提升的非常详细的文章

只是.chm文件吗? 如果是这样,它可能无法打开,因为默认情况下,不受信任位置的chm文件被阻止。 参见: KB902225 本文看来,即使仅通过首先启动Sysinternals stream.exe(如本文中所述),您也可以以编程方式解除对它们的阻止。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM