首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么用VB监测电脑是否安装了pdf阅读器,如果安装就调用它打开一个文档,没有安装就提示没安装

2013-06-19 
如何用VB监测电脑是否安装了pdf阅读器,如果安装就调用它打开一个文档,没有安装就提示没安装如何用VB监测电

如何用VB监测电脑是否安装了pdf阅读器,如果安装就调用它打开一个文档,没有安装就提示没安装
如何用VB监测电脑是否安装了pdf阅读器,如果安装就调用它打开一个文档,没有安装就提示没安装 vb?检测应用程序
[解决办法]
直接尝试打开:


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 Long

Private Sub Command1_Click()
Dim ret As Long
    ret = ShellExecute(Me.hwnd, "open", "C:\somefile.pdf", "", "", 1)
End Sub


我这里因为是有关联软件的,可以打开,ret = 42。如果没有关联软件,应该返回一个错误编码,可能是 31。
[解决办法]
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 是指定文件未找到。你换成实际存在的文件名试试。

热点排行