Recent

Author Topic: The LazHelpHtm does not work on my Win10 System.  (Read 550 times)

jamie

  • Hero Member
  • *****
  • Posts: 2166
The LazHelpHtm does not work on my Win10 System.
« on: August 09, 2019, 12:20:36 am »
the Help Demo that comes with Lazarus fails to load Microsoft Edge.

I have both IE and Edge in the PC but I use IE most of the time.
Looking into the code of this component I have located the area of where it query's the associations for the name of the browser but in my system the shellExecute fails because I do not have the open verb assigned or something, all I know it fails to load Edge.

 If I force the function that does this to return an empty string then the rest of the code follows through like its assumes Edge does not exist and then  loads the browser the other way which in my case brings up Microsoft Edge, even though I really don't use it.

 below is code I copied  from the original and test code I added to show what I mean..
Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2.   const
  3.     Extension = '.htm';
  4.   var
  5.     BufSize: DWORD;
  6.     AResult:Widestring;
  7.   begin
  8.   Memo1.Clear;
  9.  { from Lazhelp }
  10.     BufSize := MAX_PATH;
  11.     SetLength(AResult, BufSize);
  12.     if AssocQueryStringW(ASSOCF_NOTRUNCATE, ASSOCSTR_APPID, PWChar(Extension), 'open', PWChar(AResult), BufSize) = S_OK then
  13.       SetLength(AResult, BufSize -1)
  14.     else
  15.       AResult := '';
  16.     if (AResult <> '') then
  17.       AResult := 'shell:AppsFolder\' + AResult;
  18.  // ShellExecute fails to execute MicroSoft Edge on my Win10 PC.
  19.  // But I do have Edge installed, just not my default browser
  20.  // If I force this code to return no string, then it follows through with the
  21.  // default method of locating the browser using data returned below.
  22.  {......}
  23.     Memo1.Lines.Add(Aresult); // Show Associated string.
  24.  {Added a Test here }
  25.  {This code returns the actual EXE needed }
  26.  {And on my system, Edge is started, although not the default}
  27.  {C:\WINDOWS\system32\LaunchWinApp.exe}
  28.   BufSize := MAX_PATH;
  29.   SetLength(AResult, BufSize);
  30.   if  AssocQueryStringW(ASSOCF_INIT_IGNOREUNKNOWN,
  31.     ASSOCSTR_EXECUTABLE,
  32.     Extension,
  33.     'open',
  34.     PWChar(AResult),
  35.     BufSize) = S_OK Then
  36.   SetLength(AResult,BufSize) Else AResult := GetLastError.ToString;
  37.   Memo1.Lines.Add(AResult);
  38.  
  39.   end;                            
  40.  
The second half of that code is what I put in there to obtain the actual file that needs to load for the browser.

 So it looks like the Association returned is simply reporting the browser that is going to be used for the extension but the ShellExecute fails to loaded via this method, but the other way loads EDge fine.
  Something has to be done because I can't have the only Win10 PC out there with this failing attempt.

I just realized that many of you don't have all the constants, I just attached the test app.

Edit: Excuse me I meant text Project. :D
« Last Edit: August 09, 2019, 12:57:58 am by jamie »
Number 1 at blue screen app creations!

jamie

  • Hero Member
  • *****
  • Posts: 2166
Re: The LazHelpHtm does not work on my Win10 System.
« Reply #1 on: August 09, 2019, 04:36:01 pm »
No takers on this yet?

 Well I guess I can proceed in making some corrections in the code for Browser Auto Detectiion and at least fix my installs. If anyone is interested I'll post back what I end up doing to make it
work across the board.

 I've concluded the Associated properties in the system should not be relied on for execution of the app assigned to the Open Verb in the registry and the windows OS seems to know better what to do using the standard method for location the default browser.

 Basically specking, the current method now should only use the info as to what browser is going to be started but fall back on the default method, because that is the browser that gets started anyways..

Number 1 at blue screen app creations!

Zoran

  • Hero Member
  • *****
  • Posts: 1469
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: The LazHelpHtm does not work on my Win10 System.
« Reply #2 on: August 09, 2019, 05:51:14 pm »
Please report this to bugtracker.
There is much more chance to get attention from developers.

jamie

  • Hero Member
  • *****
  • Posts: 2166
Re: The LazHelpHtm does not work on my Win10 System.
« Reply #3 on: August 09, 2019, 06:40:17 pm »
I already tried that before, way before 2.0.4 get release, no one even replied to it.

 But as I work on the problem I need to know if "pathFileExists" works with registry key strings that get returned now in the code using the AssocQueryString so I can test against that string?


 I think the issue is that, there is no easy simple way to test this without actually trying to start the browser application. If it's there the browser starts which I can not have, it's not there it simple returns a failure which is what I want.

 Apparently the ShellExecute does not have a Verb to simply verify the existence of the application in the OPEN verb key of the register or test weather its a valid file.

Number 1 at blue screen app creations!

jamie

  • Hero Member
  • *****
  • Posts: 2166
Re: The LazHelpHtm does not work on my Win10 System.
« Reply #4 on: August 09, 2019, 07:20:54 pm »
can anyone here test the example "HelpHtml" in the examples folder of laz on a Win10 system?

I am currently testing this on a Win10-64 Home premium and I do have a Win10 Pro setup just not in a convenient location at the moment.

 I think this all steams from the fact that Microsoft Edge is registered in the registry but not actually fully setup or configured correctly.

 Edge does work on my system from many other apps that have html content to show, their methods work fine here, most likely because they are using the standard approach.

 I am trying to find a work around without changing any of the Function parameters etc. so it remains still compatible with existing projects
Number 1 at blue screen app creations!

wp

  • Hero Member
  • *****
  • Posts: 6485
Re: The LazHelpHtm does not work on my Win10 System.
« Reply #5 on: August 09, 2019, 07:46:44 pm »
On my system (Win 10-64 Home, v1903),  the HelpHtml example opens Firefox. Then I switched the default browser to Edge and get the error message that 'Browser "shell:AppsFolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" not found.'
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

jamie

  • Hero Member
  • *****
  • Posts: 2166
Re: The LazHelpHtm does not work on my Win10 System.
« Reply #6 on: August 09, 2019, 10:21:17 pm »
OK, That is exactly what I am getting, too.

I can fix that by returning an empty string on a particular function and it then uses the standard method, which then loads Microsoft Edge.

 I think that code should be evaluated, it's only good to tell you what is the default browser but not good to actually load it.
 
 Frankly speaking I've never did a default browser detect that way, at least not to get a loadable path.
In file
"sysenvapis_win.inc" starting line 78, Lazarus 2.0.4 release. is the code block to replace
Code: Pascal  [Select]
  1. function GetDefaultBrowserWideByAppID: WideString;
  2. const
  3.   Extension = '.htm';
  4. var
  5.   BufSize: DWORD;
  6. begin
  7.   BufSize := MAX_PATH;
  8.   SetLength(Result, BufSize);
  9.   if AssocQueryStringW(ASSOCF_NOTRUNCATE, ASSOCSTR_APPID, PWChar(Extension), 'open', PWChar(Result), BufSize) = S_OK then
  10.     SetLength(Result, BufSize -1)
  11.   else
  12.     Result := '';
  13.   if (Result <> '') then
  14.     Result := 'Shell:AppsFolder\' + Result;
  15.    { The ShellExecute does not start MicroSoft Edge With it's return value}
  16.    { Numming it for now so that it will work }
  17.    Result := ''; // Added by Jamie 8/9/2019 to void this function.
  18. end;
  19.  
  20.  
some one with some DEV status or patch status should offer this up, This is what I will be doing.
Number 1 at blue screen app creations!

Zoran

  • Hero Member
  • *****
  • Posts: 1469
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: The LazHelpHtm does not work on my Win10 System.
« Reply #7 on: August 10, 2019, 12:07:26 pm »
Again, it will probably be lost in forum, please report it.

jamie

  • Hero Member
  • *****
  • Posts: 2166
Re: The LazHelpHtm does not work on my Win10 System.
« Reply #8 on: August 10, 2019, 05:46:54 pm »
Ok, it's reported, once again!
Number 1 at blue screen app creations!