.NET WPF的Process.Start()不工作在Vista和Windows 7工作、Process、NET、WPF

2023-09-04 23:25:20 作者:几近狂妄

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

I have WPF application. After testing my app on Windows7 and realized that opening help does not work.

基本上打开CHM帮助文件,我呼吁:

Basically to open chm help file I call:

Process.Start("help.chm");

和没有任何反应。我也曾尝试我在Vista SP1中,相同的结果的应用程序。 我是小编在这两个OS'es

And nothing happens. I have also tried my app on Vista SP1, same result. I'm admin in both OS'es

我用Google搜索这个问题,但还没有找到解决的办法。

I have googled this problem, but have not found solution to it.

有没有办法解决这个问题?

Is there way to solve this problem?

你有没有经历过这种类型的不兼容问题。

Have you experienced this types of incompatibilities.

感谢您!

推荐答案

你试过的ShellExecute?

have you tried ShellExecute ?

使用了System.Runtime.InteropServices;

using System.Runtime.InteropServices;

[的DllImport(SHELL32.DLL,字符集= CharSet.Auto)         静态外部布尔的ShellExecuteEx(REF SHELLEXECUTEINFO lpExecInfo);

[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;
}

您可以尝试启动过程:

and you can try to start process with :

        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 )