SOLVED

Call to HtmlHelp() fails after desktop app is installed by MSIX.

%3CLINGO-SUB%20id%3D%22lingo-sub-2969914%22%20slang%3D%22en-US%22%3ECall%20to%20HtmlHelp()%20fails%20after%20desktop%20app%20is%20installed%20by%20MSIX.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2969914%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EAfter%20using%20MSIX%20Packaging%20Tool%20to%20convert%20an%20msi%20installer%20for%20my%20Windows%20desktop%20app%20to%20an%20msix%20installer%2C%20a%20call%20my%20app%20makes%20to%20HtmlHelp()%20fails%20to%20display%20the%20.chm%20file%20installed%20along%20with%20the%20.exe%20file.%20That%20call%20occurs%20when%20the%20user%20clicks%20%22User's%20Guide%22%20in%20the%20Help%20menu%2C%20so%20it%20is%20an%20important%20document%20that%20needs%20to%20be%20accessible%20to%20the%20user.%20Is%20there%20a%20way%20to%20allow%20a%20desktop%20app%20installed%20via%20MSIX%20to%20display%20a%20chm%20file%20or%20an%20html%20file%3F%20Or%20any%20kind%20of%20document%20file%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2970127%22%20slang%3D%22en-US%22%3ERe%3A%20Call%20to%20HtmlHelp()%20fails%20after%20desktop%20app%20is%20installed%20by%20MSIX.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2970127%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1220160%22%20target%3D%22_blank%22%3E%40StevenBrown-4429%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3ETo%20answer%20my%20own%20question%2C%20I%20got%20the%20call%20to%20HtmlHelp()%20to%20work%20by%20making%20it%20access%20a%20chm%20file%20not%20installed%20into%20%22Program%20Files%5CWindows%20Apps%22%2C%20a%20directory%20owned%20and%20restricted%20by%20Microsoft%2C%20but%20into%20a%20non-restricted%20directory%20on%20the%20computer.%3CBR%20%2F%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2971805%22%20slang%3D%22en-US%22%3ERe%3A%20Call%20to%20HtmlHelp()%20fails%20after%20desktop%20app%20is%20installed%20by%20MSIX.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2971805%22%20slang%3D%22en-US%22%3EBut%20now%20there%20is%20another%20problem.%20After%20the%20MSIX%20install%2C%20a%20call%20my%20app%20makes%20to%20HtmlHelp()%20succeeds%20if%20the%20file%20already%20exists%20as%20C%3A%5CUsers%5CPublic%5CDocuments%5CMyApp%5CUsersGuide.chm.%20However%2C%20if%20MyApp%5CUsersGuide.chm%20does%20not%20already%20exist%2C%20the%20MSIX%20install%20fails%20to%20create%20that%20subdirectory%20and%20file.%20The%20msi%20file%20succeeds%20at%20that%20task%2C%20but%20the%20msix%20file%20it%20is%20converted%20to%20fails.%20Why%20is%20that%3F%20Why%20does%20MSIX%20fail%20to%20create%20a%20subfolder%20and%20copy%20a%20chm%20file%20into%20a%20non-restricted%20directory%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2971969%22%20slang%3D%22en-US%22%3ERe%3A%20Call%20to%20HtmlHelp()%20fails%20after%20desktop%20app%20is%20installed%20by%20MSIX.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2971969%22%20slang%3D%22en-US%22%3EI%20gained%20access%20in%20File%20Explorer%20to%20the%20Program%20Files%5CWindowsApps%20directory%20and%20found%20the%20chm%20file%20was%20installed%20into%20a%20VFS%20folder.%20Now%20I%20need%20to%20find%20a%20way%20for%20my%20desktop%20app%20to%20access%20that%20file.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2972547%22%20slang%3D%22en-US%22%3ERe%3A%20Call%20to%20HtmlHelp()%20fails%20after%20desktop%20app%20is%20installed%20by%20MSIX.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2972547%22%20slang%3D%22en-US%22%3EThe%20problem%20is%2C%20MSIX%20installs%20the%20chm%20file%20into%20VFS%5CCommon%20Documents%5CMyApp%5CUsersGuide.chm%2C%20but%20that%20directory%20does%20not%20appear%20to%20be%20mapped%20by%20Windows%20to%20C%3A%5CUsers%5CPublic%5CDocuments%5CMyApp%5CUsersGuide.chm%2C%20because%20when%20my%20app%20calls%20HtmlHelpW(hWnd%2C%20wch_HelpPath%2C%20HH_DISPLAY_TOPIC%2C%20NULL)%2C%20where%20wch_HelpPath%20is%20a%20pointer%20to%20L%22C%3A%5CUsers%5CPublic%5CDocuments%5CMyApp%5CUsersGuide.chm%22%2C%20it%20fails.%3CBR%20%2F%3E%3CBR%20%2F%3EHow%20can%20a%20desktop%20app%20simply%20read%20a%20file%20that%20has%20been%20installed%20into%20the%20Common%20Documents%20folder%20in%20the%20VFS%3F%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

After using MSIX Packaging Tool to convert an msi installer for my Windows desktop app to an msix installer, a call my app makes to HtmlHelp() fails to display the .chm file installed along with the .exe file. That call occurs when the user clicks "User's Guide" in the Help menu, so it is an important document that needs to be accessible to the user. Is there a way to allow a desktop app installed via MSIX to display a chm file or an html file? Or any kind of document file?

6 Replies

@StevenBrown-4429

To answer my own question, I got the call to HtmlHelp() to work by making it access a chm file not installed into "Program Files\Windows Apps", a directory owned and restricted by Microsoft, but into a non-restricted directory on the computer.
 

But now there is another problem. After the MSIX install, a call my app makes to HtmlHelp() succeeds if the file already exists as C:\Users\Public\Documents\MyApp\UsersGuide.chm. However, if MyApp\UsersGuide.chm does not already exist, the MSIX install fails to create that subdirectory and file. The msi file succeeds at that task, but the msix file it is converted to fails. Why is that? Why does MSIX fail to create a subfolder and copy a chm file into a non-restricted directory?
I gained access in File Explorer to the Program Files\WindowsApps directory and found the chm file was installed into a VFS folder. Now I need to find a way for my desktop app to access that file.
The problem is, MSIX installs the chm file into VFS\Common Documents\MyApp\UsersGuide.chm, but that directory does not appear to be mapped by Windows to C:\Users\Public\Documents\MyApp\UsersGuide.chm, because when my app calls HtmlHelpW(hWnd, wch_HelpPath, HH_DISPLAY_TOPIC, NULL), where wch_HelpPath is a pointer to L"C:\Users\Public\Documents\MyApp\UsersGuide.chm", it fails.

How can a desktop app simply read a file that has been installed into the Common Documents folder in the VFS?
best response confirmed by StevenBrown-4429 (Occasional Contributor)
Solution
I solved the problem by using the C:\ProgramData folder for installing the subfolder and .chm file. That is one of the folders Windows maps to the VFS (Virtual File System) that MSIX installs to.

Hi @StevenBrown-4429, thank you for your question. Here is also a solution to your problem using the package support framework: Package Support Framework - Working Directory fixup - MSIX | Microsoft Docs