使用VB代码检测是否安装了adobe reader
我想使用VB6检测是否安装了adobe reader。 另外,如果检测到它未安装,最好的解决方案是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
访问“HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader”并枚举其子项。 通过此操作,您可以获得该计算机上存在的“Adobe Reader”(以前称为“Acrobat Reader”)安装的版本号。
您还可以查看 http://pdftohtml.sourceforge.net/
如果您找不到能够解析 pdf 文件的应用程序,您还可以将其转换为 html 并使用网络浏览器访问它,该浏览器在大多数操作系统上都可用。
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.
有一些粗略的方法(检查程序文件目录中的文件),但我建议您声明完整的注册表函数(不是来自 vb 的 getSetting),如 http://www.windowsdevcenter.com/pub/a/windows/2004/06/15/VB_Registry_Keys.html并获取
HKEY_CLASSES_ROOT\.pdf
如果那里有,那么就有能够读取 pdf 的东西(这就是你想要的,对吧?)。
作为奖励,HKEY_CLASSES_ROOT\.pdf\OpenWithList 有一个打开 .pdf 文件的已注册应用程序列表(哇)...该列表上的键名称是您可以使用 从 vb 调用的程序>shell("开始"+ OpenAppName)
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)
我会检查“
浏览该列表”将为您提供所有已安装的程序。 查找应用程序特定的注册表项通常会起作用,但有时在卸载应用程序时,它会将它们留下。
类根目录适合显示是否安装了 PDF 阅读器。
另外,如果您只想使用默认应用程序来处理 PDF,您可以使用以下命令。 (这是在 VBScript 中,但在 VB6 上应该同样工作)
对评论的回应
在 vb6 中访问注册表有几种方法,RegRead 就是其中之一。 WMI 是另一种方式。 我会使用 WMI,因为您可以轻松枚举子项。
读取 HKEY_CLASSES_ROOT 没有任何问题,但如果您只是要启动默认的 pdf 处理程序,为什么不直接使用上面的 WshShell.Run 命令运行它呢? 您可以少一步完成同样的事情。
I would check in the
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)
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.