[英].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 )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.