Prianca
Prianca

Reputation:

Detect whether adobe reader is installed using VB code

I want to detect whether adobe reader is installed using VB6. Also if detected that it's not installed, what would be the best solution?

Upvotes: 3

Views: 6523

Answers (3)

Rob Haupt
Rob Haupt

Reputation: 2144

I would check in the

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

Going through that list will give you all the programs installed. Looking for Application Specific Registry Entries typically will work, but occasionally when uninstalling an application, it will leave them behind.

The Class Root is good for showing if any PDF Reader is installed.

Also, if you just want to use the default application to handle PDFs you can us the following. (This is in VBScript, but it should work the same on VB6)

File = <PDF FILE HERE>
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run Chr(34) & File & Chr(34)

Response to comments

There are a few ways to access the registry in vb6, RegRead is one. WMI is another way. I would use WMI since you can enumerate subkeys easily.

There is nothing wrong with reading HKEY_CLASSES_ROOT, but if you were just going to launch the default pdf handler why not just run it with the WshShell.Run command above? Your accomplishing the same thing with one less step.

Upvotes: 0

jpinto3912
jpinto3912

Reputation: 1465

There are crude ways (checking for files on Program files directory), but I'd recommend you declare full-registry functions (not getSetting from vb) as in http://www.windowsdevcenter.com/pub/a/windows/2004/06/15/VB_Registry_Keys.html and fetch

HKEY_CLASSES_ROOT\.pdf

If that's there, something capable of reading pdfs is there (which is what you want, right?).

As a bonus, HKEY_CLASSES_ROOT\.pdf\OpenWithList has a list (wow) of registered applications that open .pdf files... the key names on that list are programs you can invoke from vb using shell("start "+ OpenAppName)

Upvotes: 1

bot47
bot47

Reputation: 1514

Access "HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader" and enumerate its subkeys. By that you get the versionnumbers of the installations of "Adobe Reader" (formerly "Acrobat Reader") that exist on this computer.

You might also have a look at http://pdftohtml.sourceforge.net/ If you cannot find an application which is able to parse pdf files, you may also convert it to html and access it with a webbrowser, which is available on most operating systems.

Upvotes: 1

Related Questions