views:

663

answers:

3

Hello,

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

Basically to open chm help file I call:

Process.Start("help.chm");

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

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.

Thank You!

+1  A: 

This SO thread should help you. Also, here's a pretty detailed article on UAC and how to elevate.

JP Alioto
+2  A: 

have you tried ShellExecute ?

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

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)

What's the difference between pinvoking ShellExecute directly and calling ProcessStart(ProcessStartInfo) with UseShellExecute=true ?
Nir
+1  A: 

Is it just .chm files? If so it may not be opening because, by default, chm files in untrusted locations are blocked. See: KB902225. From this article it appears that you may be able to unblock them programmatically, even if it's just by launching Sysinternals streams.exe first (as referenced in the article).

Factor Mystic