我有WPF应用程序。 在Windows7上测试我的应用程序并意识到打开帮助不起作用。
基本上打开chm帮助文件我打电话:
Process.Start("help.chm");
没有任何反应。我也在Vista SP1上试过我的应用程序,结果相同。 我是两个操作系统的管理员
我已经搜索了这个问题,但还没有找到解决方法。
有办法解决这个问题吗?
您是否遇到过这种类型的不兼容问题。
谢谢!
答案 0 :(得分:3)
你试过ShellExecute吗?
使用System.Runtime.InteropServices;
[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;
}
您可以尝试使用以下命令启动流程:
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)
答案 1 :(得分:1)
这SO thread应该可以帮到你。此外,这是UAC上的pretty detailed article以及如何提升。
答案 2 :(得分:1)
它只是.chm文件吗?如果是这样,它可能无法打开,因为默认情况下,不受信任位置的chm文件被阻止。见:KB902225。从this article开始,您似乎可以通过编程方式取消阻止它们,即使它只是首先启动Sysinternals streams.exe(如文章中所述)。