Home Forums DITA and XMetaL Discussion Opening XHTML file in Xmetal from map Reply To: Opening XHTML file in Xmetal from map

Derek Read

Reply to: Opening XHTML file in Xmetal from map

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;
}
}[/code]

In theory what normally happens (when you have not made any file association changes yourself) for a path like C:myfoldermyfile.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_ROOThtmlfile
5. It then looks for the subkey shellopencommand and should find HKEY_CLASSES_ROOThtmlfileshellopencommand
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):

HKUSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.htmlApplication

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).

Reply

Products
Downloads
Support