使用前请先检查是否已安装Adobe Reader [英] Check if Adobe Reader is installed before using it

查看:425
本文介绍了使用前请先检查是否已安装Adobe Reader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的应用能够检查是否已安装Adobe Reader. 如果是这样,我希望我的程序使用它来显示PDF,否则,我想使用我的免费(有限)阅读器控件来显示PDF.

I want to be able to have my app check if Adobe Reader is installed. If it is, I want my program to use it to display the PDF, if not I want to use my free (limited) reader control to display the PDF.

任何建议

我的问题似乎不大 所以基本上我正在尝试执行以下操作

my question seems to be little to broad So basicly i'm trying to do the following

Try
   Dim AcroDisplay As New AxAcroPDFLib.AxAcroPDF

   AcroDisplay.Left = 50
   AcroDisplay.Top = 50
   AcroDisplay.Width = 200
   AcroDisplay.Height = 500
   me.Controls.Add(AcroDisplay)
   MsgBox("Acro Added")
Catch ex As Exception
   MsgBox("Acro Not installed")
   ''Load Alternate PDF viewer (Spire.pdf Free)
End Try

但是,当未安装Acrobat而不是转到catch语句时,它只会显示错误无法加载程序集",然后退出子程序

However when Acrobat Isn't installed instead of going to the catch statement it just shows an error "Could not load assembly" and then exits the sub

我想要的是,如果未安装acrobat控件,它将不会显示和错误,而是仅加载备用pdf查看器

What i want is that if acrobat control isn't installed, that it wont display and error and instead just load the alternate pdf viewer

是否可以在尝试加载之前检查AxAcroPDFLib.AxAcroPDF?

is there a way to check for AxAcroPDFLib.AxAcroPDF before attempting to load?

希望这使事情更清楚

搜索并拧紧后,我发现了2种可能的方式,我可能能够做到这一点 但是我两者都无法在VB.net中找到方法

Edit 2: After Searching and screwing around i found 2 possible ways i might be able to do this however both i can't find how to do it in VB.net

第一 在可用的名称空间中查找AxAcroPDFLib.AxAcroPDF 找到了C#示例,但我不知道如何将其更改为Vb.net C#-如何检查是否C#中是否存在名称空间,类或方法??

First Look for AxAcroPDFLib.AxAcroPDF in available namespaces found C# example but i don't know how to change it to Vb.net C# - How to check if namespace, class or method exists in C#??

第二 添加未处理的异常处理程序 也找到了一些例子,但似乎没有用

Second Add Unhandled Exception Handler also found a few examples but none seem to work

任何机会,任何人都可以将我介绍给这些选项中的一个(或两个)的可行示例

Any Chance anyone could direct me to a working example for either (or both) of these options

推荐答案

试图找到一个可行的解决方案,不符合我最初的想法,但确实可以正常工作

Manged to fin a working solution, doesn't work how i was originally thinking but it doe work just fine

我使用了以下代码

    Dim AdobeSoftwares As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("ADOBE")
    If AdobeSoftwares Is Nothing Then
        'MessageBox.Show("No Adobe Software")
        Dim PdfDisplay As New PdfiumViewer.PdfViewer 
        PDFControl = "Pdfium"
    Else
        If Not Array.IndexOf(AdobeSoftwares.GetSubKeyNames, "Acrobat Reader") = -1 Then
            'MessageBox.Show("Adobe Reader Installed")
            Dim PdfDisplay As New AxAcroPDFLib.AxAcroPDF
            PDFControl = "Acrobat"
        Else
            'MessageBox.Show("Adobe Reader Not Installed")
            Dim PdfDisplay As New PdfiumViewer.PdfViewer
            PDFControl = "Pdfium"
        End If
    End If

然后在我的显示代码中,我只是想看看正在使用的"PDFControl"并运行相关代码以在该显示器中显示

Then in my display code i just look to see what "PDFControl" is in use and run the relevant code to display in that display

因此,如果现在安装了Adobe Reader,则将使用其控件,如果未安装,则将使用免费(但功能较少的控件)显示PDF文件 所以希望如果有人正在做与我相似的事情,那么他们可以

So now if adobe reader is installed, I'll be using its control, and if it isn't I'll be using the free (but less featured) control to display PDF files So hopefully if anyone else is looking at doing similar to me then they can

这篇关于使用前请先检查是否已安装Adobe Reader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆