http - ShellExecute fails for local html or file URLs -
Our company is migrating our help systems to HTMLMF format under the flyer. We have a URI command line But the flare has also been added to a topic based basis on systems that use CSHID, such as index.html # CSHID = GetStarted.html GetStarted to Launch Help Page
Our apps are written in C ++ and take advantage of the Win32 ShellExecute () function to make the default app associated with HTTP to display the help system. We've found that when a hashtag is not specified, such as ShellExecute () works fine, like
ShellExecute (NULL, _T ("Open"), _ T ("c: \ help \ Index.html "), NULL, NULL, SW_SOWNOWNMAL);
This function will launch the default browser related to viewing HTML pages and in this case, the file: /// Protocol handlers will kick, the browser will launch and you see the file in the address bar: /// c : /help/index.html.
However, once the topic # Add information, ShellExecute fails to open the page
ShellExecute (NULL, _T ("open"), _ T (" C: \ help \ index.html # cshid = Get Started "), Zero, Zero, SW_SOWNOWNMAL)
Even if the browser opens, you will be directed to the file: /// c: / Help / index.html # cshid = Received-Started Subject Without Identity
Note that this is only a problem if the file protocol handler is connected via the shellExecute (), if the support system stays on the Web, and the HTTP or HTTTP handler is busy, everything is great Works.
For our customer, some of which are on the private LAN, we can not always rely on internet access, so our help system should be required with the application. After a few backs and more with Microsoft's MSDN team, they have the source code in ShellExecute () call.
The solution was to beef up ShellXsecute () by searching the URL for # and if we found any, we manually launch the default browser with the URL. Here is the pseudocode
Void WebDrive_ShellExecute (LPCTSTR szURL) {if (_tcschr (szURL, _T ('#')) // // Get the default browser from the Registry, then launch it. //: RegGetStr (HKCR, _T ("HTTP \\ shell \\ open \\ command"), asbestoser); :: create process (zero, szBrowser + _T ("") + szURL, zero, zero, false, 0, zero, zero, and needle, and pi); } And shellexecute (NULL, _T ("Open"), Ses URL, Faucet, TL, SW_SOWNOWNMAL); } It is valid that the C ++ code is slightly higher, but this general design works for us.
Comments
Post a Comment