1. Philippe ALLAiS
  2. PowerBuilder
  3. Thursday, 9 May 2019 16:31 PM UTC

Hello,

 

In Powerbuilder 17 R3, I need to open an URL in the default browser of my computer.

Chrome is my default browser.

But with the next code, IE is opened instead of Chrome.  

 

Is it normal ?

Please, how can I do to open this URL with the default browser ?

 

I wrote this code :

int	li_rc
string	ls_url
INet	linet

linet = create INet

TRACE.log(THIS.ClassName() + ".ue_notif_courrier(DEBUT)")

ls_url = gnv_app.of_getURL("http://www.topaze.com")	

// Appelle la page web
li_rc = this.GetContextService("Internet", linet)
if li_rc = 1 then 
	li_rc = linet.HyperlinkToURL(ls_url)	// Ouvre IE au lieu du navigateur par défaut !!!!
	//run("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe " + ls_url)
end if

if isvalid(linet) then destroy linet

 

 

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 28 February 2023 01:33 AM UTC
  2. PowerBuilder
  3. # 1

BTW: there is a known bug of HyperLinkToURL() to ignore the default browser when running PB applications on Windows 10 or later in versions pre-PB 2017, like PB12.6. On windows 7 it would work correctly.

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 7 September 2020 20:42 PM UTC
  2. PowerBuilder
  3. # 2

I've seen something similar happening when setting Thunderbird as the default email client: still opens up Outllook.

I think the real problem here is that W10 is a piece of crap.

Comment
There are no comments made yet.
Luis Carlos González Bárcenas Accepted Answer Pending Moderation
  1. Monday, 7 September 2020 10:04 AM UTC
  2. PowerBuilder
  3. # 3

Maybe is a late answer but could help someone.

At Windows registry you can find the default web browser in:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice

Hope this help

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 14 May 2020 18:38 PM UTC
  2. PowerBuilder
  3. # 4

Hi,

Though you already solved the problem, I think you could use the same solution as I suggested on https://community.appeon.com/index.php/qna/q-a/windows-api-to-find-an-installed-program

ShellExecute API. It's very simple and should open with default browser:

I've attached a little PB2017 R3 sample application right here.

regards.

Attachments (1)
Comment
  1. And And
  2. Monday, 27 February 2023 13:15 PM UTC
Thanks a lot, Miguel!

This code works great for Windows10!

The default browser opens, not IE.



Function long ShellExecute( long hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, integer nShowCmd) Library "shell32.dll" alias for "ShellExecuteW"



String ls_null

setnull(ls_null)

Long ll_handle

ll_handle = Handle(Parent) // ll_handle = Handle(mdiframe) // setnull(ll_handle)

ShellExecute( ll_handle, "Open", "https://...";;, ls_null, "", 1)
  1. Helpful
  1. And And
  2. Monday, 27 February 2023 13:18 PM UTC
Correct line:



ShellExecute( ll_handle, 'Open', 'https://...', ls_null, '', 1)
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 27 February 2023 13:20 PM UTC
Great to hear.

Don't forget to have a look also at https://community.appeon.com/index.php/qna/q-a/shellexecutew It's not always the 'Open' command that does the trick.

What I'm doing now, is first try with 'Open', if not successful, I try 'Edit' and if that didn't work either, I pass in a null value.

regards.
  1. Helpful
There are no comments made yet.
Philippe ALLAiS Accepted Answer Pending Moderation
  1. Monday, 13 May 2019 11:57 AM UTC
  2. PowerBuilder
  3. # 5

Finally, I do the modification of the registry with a registryset() and the problem is the same.

I make this code and the registry key is modified but it's IE browser which is opened


int li_rc
string ls_url, ls_datas, ls_cle_nav_defaut, ls_nav_defaut, ls_nav_desire
INet linet

linet = create INet

ls_url = "http://www.topaze.com"

// Recherche du navigateur par défaut
li_rc = RegistryGet("HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", "ProgId", RegString!, ls_cle_nav_defaut)

// Recherche du chemin d'accès au navigateur par défaut
li_rc = RegistryGet("HKEY_CLASSES_ROOT\http\shell\open\command", "", RegString!, ls_nav_defaut)

// Recherche du chemin d'accès au navigateur réel en base de registre
li_rc = RegistryGet("HKEY_CLASSES_ROOT\" + ls_cle_nav_defaut + "\shell\open\command", "", RegString!, ls_nav_desire)

// Si les 2 sont différents, il faut modifier le navigateur par défaut
if ls_nav_defaut <> ls_nav_desire then
	// Modifie les HTTP
	li_rc = RegistrySet("HKEY_CLASSES_ROOT\http\shell\open\command", "", RegString!, ls_nav_desire)

	// Modifie les HTTPS
	li_rc = RegistrySet("HKEY_CLASSES_ROOT\https\shell\open\command", "", RegString!, ls_nav_desire)
end if

// Appelle la page web
li_rc = this.GetContextService("Internet", linet) 

if li_rc = 1 then 
	li_rc = linet.HyperlinkToURL(ls_url) // Ouvre IE au lieu du navigateur par défaut !!!!
end if

 

Only the run on the browser I find in "HKEY_CLASSES_ROOT\" + ls_cle_nav_defaut + "\shell\open\command" works

 

Regards

Philippe

Comment
There are no comments made yet.
Philippe ALLAiS Accepted Answer Pending Moderation
  1. Friday, 10 May 2019 15:07 PM UTC
  2. PowerBuilder
  3. # 6

Thanks Chris for this link : https://stackoverflow.com/questions/32354861/how-to-find-the-default-browser-via-the-registry-on-windows-10

 

So I think there is a bug in Powerbuilder 17 R3 with Windows 10 because :

In my registry : "HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice"
I have the "ProgId" = "ChromeHTML"

When I search the default progID in the registry :
"HKEY_CLASSES_ROOT\http\shell\open\command"
I have : "C:\Program Files\Internet Explorer\iexplore.exe" %1

And if I search the prodId
"HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command"
I have : "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -- "%1"

 

So Powerbuilder 17 R3 in windows 10 don't take the good information for the default browser, isn't it ?

 

Regards

Philippe

 

Comment
  1. Chris Pollach @Appeon
  2. Monday, 13 May 2019 18:56 PM UTC
Hi Phillipe;

I just did it manually by using the RegEdit utility. Then I clicked on an .HTML file and it still opened a new tab page in my already open FF. However, when I closed FF and then double-clicked on the .HTML file again - it said that there was no default browser and the O/S then prompted me to choose one. So the above RegEdit path & setting (I think) is OK - but, its not the only one that your PB App needs to set ... unforgettably. :-(

Still continuing to look into this deeper for you.

Regards ... Chris
  1. Helpful
  1. Philippe ALLAiS
  2. Tuesday, 14 May 2019 07:51 AM UTC
Hi Chris,



Thanks a lot for your help.



I "resolve" this problem by using the run command with the path find with the 2 registry keys :

* HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice : to find the browser by the progId to use

* HKEY_CLASSES_ROOT\ + ProgId found + \shell\open\command : the "exe" command to use to open the browser found



This is OK in windows 10, and I must try it in windows 8 and 7 SP1 to be sure it's OK all the time. But no computer with these OS...



Regards

Philippe





  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 14 May 2019 16:35 PM UTC
Hi Philippe;

Thank you for that feedback ... good to know!

Regards ... Chris
  1. Helpful
There are no comments made yet.
Philippe ALLAiS Accepted Answer Pending Moderation
  1. Friday, 10 May 2019 07:54 AM UTC
  2. PowerBuilder
  3. # 7

Hi Chris

 

In my PC, I have really Chrome like default browser, I think. 

And when I click on a link in a mail or others, chrome is opened to edit the URL.

 

In IE 11, I have :

 

I forgot to say that the PC is in Windows 10.

 

There is something to do in the registry to confirm that ?

 

Regards

Philippe

 

 

 

Comment
  1. DIPANJAN DUTTA
  2. Friday, 10 May 2019 10:27 AM UTC
HI Philippe...Agree with U........I had tried you code ........it give me same result...
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 9 May 2019 16:52 PM UTC
  2. PowerBuilder
  3. # 8

Hi Phillipe;

   Then IE is still really your "default" web browser.

   When I use the iNet command on my development PC it opens the URL in my FF web browser which is that machine's default web browser. When I use this command on my test PC, it opens the URL in my Chrome browser which is the default for that machine.

Regards ... Chris

Comment
  1. Scott Mason
  2. Thursday, 14 May 2020 17:45 PM UTC
The GetContextService("Internet") reads the registry key



HKEY_CLASSES_ROOT\htmlfile\shell\open\command



which is set to IE by default. This setting in not affected by changing the default WebBrowser or default app.

If change the key to point at Chrome, I get Chrome.

  1. Helpful
  1. Trevor Holyoak
  2. Monday, 14 September 2020 23:03 PM UTC
I am having the same problem. So it looks like PowerBuilder is looking at the wrong registry key and we're going to have to do this the hard way?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.