Pages: 1
Print
Author Topic: Opening XHTML file in Xmetal from map  (Read 2707 times)
gcrews
Member

Posts: 265


« on: August 09, 2012, 05:00:56 PM »

How can I get XHTML files to open in XMetaL that are linked in a ditamap? If .html files are associated with IE then they open fine in IE when you double click them in in Xmetal. If I set the default program for .html to Xmetal (witch isn’t the best solution) and I double click on on in a map in XMetaL, XMetaL says "This file does not have a program associated with it for performing this action…" despt it opening fine from Explore in Xmetal.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: August 10, 2012, 01:01:04 PM »

No solution for you, but I'm looking into it. Microsoft has me stumped here so far.



I can reproduce something like this on one of my machines and I think it is your issue. No matter what "normal" steps I do to associate opening .html files with an application (any application) the files still open in IE.  "Normal" here means using Windows Explorer to associate file extensions, not hand editing the registry.

The mysterious thing is that our code simply asks Windows to "shell execute" the file, passing it the "open" action. This lets Windows decide which application should do the open and I would expect that to function exactly the same as if you double click on a file in Windows Explorer.

The actual code is as follows (the relevant line is the "ShellExecute" method):

Code:
XM.openExternal = function(filepath)
{
if (XM.String.hasContent(filepath)) {
   var objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute(filepath, "", "", "open", 1);
objShell = null;
}
}

In theory what normally happens (when you have not made any file association changes yourself) for a path like C:\myfolder\myfile.html is the following:
1. ShellExecute parses the URL and extracts the ".html" portion. [Note: if it finds "http", "ftp", etc, at the start then another path through the registry is taken.]
2. It then looks for a matching registry key in HKEY_CLASSES_ROOT\ and should find HKEY_CLASSES_ROOT\.html
3. It extracts the (default) value, which will normally be "htmlfile".
4. It then looks for a matching registry key in HKEY_CLASSES_ROOT\ and should find HKEY_CLASSES_ROOT\htmlfile
5. It then looks for the subkey \shell\open\command and should find HKEY_CLASSES_ROOT\htmlfile\shell\open\command
6. The value for (default) should normally be used.

XMetaL itself does not set such values (we don't try to take over file extension associations for double click like many other apps do mostly because we integrate with many 3rd party systems so it is best to let them set this up).

However, when you use Windows Explorer to associate a file extension with an application the following is set, and it is this value that should (as far as I know) get first crack at it (ie: if it exists then it should take precedence):

HKU\<some big long id representing your Windows account>\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\Application

This makes me think that Microsoft is doing some chicanery here, somehow bypassing (what I think is) the "normal" routine that is not obvious to me yet. Either that, or I don't properly understand the workings of ShellExecute.

I don't think we can improve our code here. There is no better way to do this as far as I can tell. So, what I will try to look for is the magic registry entry that needs to be set (assuming there is one).
« Last Edit: August 10, 2012, 01:02:57 PM by Derek Read » Logged
gcrews
Member

Posts: 265


« Reply #2 on: August 10, 2012, 04:11:04 PM »

This is kind of a hack but it seems to work. If I make a copy of the xmetal60.exe file, say xmetal60.copy.exe and then associate .html files with xmetal60.copy.exe the   .html links will open from a map. Since I suspect XMetaL is doing instance checking the xmetal60.copy.exe executable never fully opens another instance but the file gets passed back to the original xmetal60.exe.

Now that I know when that external trigger code is I will likely just change how Xmetal handles .html files and not the system. That works better to because IE would always want to reset .html to IE as the default program. Thanks for the help.
Logged
Pages: 1
Print
Jump to:  

email us