如何用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
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. '