1. Richard Frantz
  2. PowerBuilder
  3. Wednesday, 13 May 2020 22:40 PM UTC

Is there a Win Api to determine if a program is installed or not?

PB 12.5

Mix of Win 7 and Win 10

Our app has an acrobat ole control for viewing PDF's, but as we move to Win 10 not everyone has Acrobat installed, and some want to use Nitro PDF.

I have both installed, so it is easy to stack ole controls on the Window, I'm just at a loss how to determine if Nitro is installed or not to know which control to hide/show.

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 14 May 2020 11:41 AM UTC
  2. PowerBuilder
  3. # Permalink

I believe in respecting a users choice of PDF editor. PDF editors might be changed now and then and there'll always be the odd user who uses something else as what's assumed.

Therefore personally I use the ShellExectute() API command to open a PDF file with whichever "default" has been configured in windows for viewing:

Local External function declaration:

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

Call to open a (pdf) file:

setnull(ls_null)
ll_handle = Handle(Parent)// setnull(ll_handle) // 
ShellExecute( ll_handle, 'Open', ls_filename, ls_null, ls_applicationDir, 1)

In previous example, "Handle(parent)" is the handle to the "window".
The last parameter determines how to open the associated application: last used, maximized, etc. 
https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutew

To obtain information about the application that is launched as a result of calling ShellExecute, use ShellExecuteEx.

regards

Comment
  1. And And
  2. Monday, 27 February 2023 13:14 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:25 PM UTC
Correct line:



ShellExecute( ll_handle, 'Open', 'https://...', ls_null, '', 1)
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 27 February 2023 14:25 PM UTC
I don't know why my last comment disappeared, so here it is again:

Please have a look at: https://community.appeon.com/index.php/qna/q-a/shellexecutew

Sometimes 'Open' is not the correct parameter. I have image files associated to ms-paint and for that one, I have to pass 'Edit'. If neither 'Open' nor 'Edit' works, pass in a null value. It should work with either of these 3 possible values. The API returns a value, so you can check on that.

regards.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 27 February 2023 14:27 PM UTC
  2. PowerBuilder
  3. # 1

You can look under these registry keys to see what has been installed:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall

 

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Thursday, 14 May 2020 23:51 PM UTC
  2. PowerBuilder
  3. # 2

FYI -

   Just today I got fed up with how Windows 10 was sending my PDF files to MS Edge.

   No, I'm not kidding. Yes, that PDF viewer is atrocious.

   I downloaded Adobe Reader and set the file association to resolve that issue.

   Then, out of spite, I disabled Edge. Heh.


Later -

Olan

Comment
  1. Chris Pollach @Appeon
  2. Friday, 15 May 2020 01:25 AM UTC
Olan ... Microsoft web browser ... The "best" browser to use to get the web browser that you really wanted. ;-)
  1. Helpful
  1. Olan Knight
  2. Friday, 15 May 2020 13:05 PM UTC
*Snort* :)
  1. Helpful
  1. Roland Smith
  2. Monday, 27 February 2023 13:49 PM UTC
Microsoft and Adobe announced a partnership where Adobe will provide the PDF viewer within Edge. The new version of Edge with that built in will come out sometime in March.
  1. Helpful
There are no comments made yet.
Richard Frantz Accepted Answer Pending Moderation
  1. Thursday, 14 May 2020 17:10 PM UTC
  2. PowerBuilder
  3. # 3

The team decided it was best to not revisit this issue down the line, and send the PDF to Windows to allow the default PDF viewer that the user decided on to take over.

Comment
There are no comments made yet.
Richard Frantz Accepted Answer Pending Moderation
  1. Thursday, 14 May 2020 14:57 PM UTC
  2. PowerBuilder
  3. # 4

Thank you Armeen and Miguel. Both are good suggestions. I will bring them to the team and we will discuss.

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 13 May 2020 23:06 PM UTC
  2. PowerBuilder
  3. # 5

If you simply want to view PDFs, how about loading it up in the new Chromium WebBrowser control of PowerBuilder 2019 R2? This would remove dependency on client PDF software. 

The issue I see is that Adobe and Nitro is not going to cover the PDF universe so you may still run into issues.

The other issue I see is that the user's OS security configuration may block you from being able to check what programs installed.

Comment
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.