如何用VB监测电脑是否安装了pdf阅读器,如果安装就调用它打开一个文档,没有安装就提示没安装vb 检测应用程序

解决方案 »

  1.   

    具体怎么实现呢,pdf软件有很多,怎么检测只要有一款就行呢
      

  2.   

    具体怎么实现呢,pdf软件有很多,怎么检测只要有一款就行呢
      

  3.   

    直接尝试打开:Option Explicit
    Private Declare Function ShellExecute _
        Lib "shell32.dll" Alias "ShellExecuteA" _
        ( _
        ByVal hwnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As Long _
        ) As LongPrivate Sub Command1_Click()
    Dim ret As Long
        ret = ShellExecute(Me.hwnd, "open", "C:\somefile.pdf", "", "", 1)
    End Sub我这里因为是有关联软件的,可以打开,ret = 42。如果没有关联软件,应该返回一个错误编码,可能是 31。
      

  4.   

    那应该会返回错误码SE_ERR_NOASSOC 
      

  5.   

    Const ERROR_BAD_FORMAT = 11&
    Const ERROR_FILE_NOT_FOUND = 2&          
    Const ERROR_PATH_NOT_FOUND = 3&          ' The specified path was not found. '
    Const SE_ERR_ACCESSDENIED = 5            ' The operating system denied access to the specified file. '
    Const SE_ERR_ASSOCINCOMPLETE = 27        ' The file name association is incomplete or invalid. '
    Const SE_ERR_DDEBUSY = 30                ' The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed. '
    Const SE_ERR_DDEFAIL = 29                ' The DDE transaction failed. '
    Const SE_ERR_DDETIMEOUT = 28             ' The DDE transaction could not be completed because the request timed out. '
    Const SE_ERR_DLLNOTFOUND = 32            ' The specified dynamic-link library (DLL) was not found. '
    Const SE_ERR_FNF = 2                     ' The specified file was not found. '
    Const SE_ERR_NOASSOC = 31                ' There is no application associated with the given file name extension. '
    Const SE_ERR_OOM = 8                     '  out of memory '
    Const SE_ERR_PNF = 3                     '  path not found '
    Const SE_ERR_SHARE = 26                  ' A sharing violation occurred. '错误编码 2 是指定文件未找到。你换成实际存在的文件名试试。