.NET WPF的Process.Start()不工作在Vista和Windows 7 [英] .NET WPF Process.Start() not working on Vista and Windows 7

查看:210
本文介绍了.NET WPF的Process.Start()不工作在Vista和Windows 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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

这篇关于.NET WPF的Process.Start()不工作在Vista和Windows 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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