I need to know if there is any way to detect in a client PC (Windows) there any PDF reader (Adobe Reader, Foxit Reader, ...), using VB6 and. NET (C #).
I can not do by reading the Windows registry, because the user may not have permissions to read it.
Thank you.
A sample based on Jerry Coffin's suggestion to use FindExecutable
(based on this article):
Private Declare Function FindExecutable Lib "shell32.dll" _
Alias "FindExecutableA" ( _
ByVal lpFile As String, _
ByVal lpDirectory As String, _
ByVal lpResult As String) As Long
Private Declare Function lstrlen Lib "kernel32.dll" _
Alias "lstrlenA" ( _
ByVal lpString As Any) As Long
' FindExecutable Constants
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
Private Sub Command1_Click()
Dim Retval As Long, buffer As String
' init buffer
buffer = Space(256)
Retval = FindExecutable("c:\windows\media\tada.wav", "", buffer)
Select Case Retval
Case 0
Debug.Print "Not enough memory to execute this method."
Case 31
Debug.Print "No file association found."
Case ERROR_FILE_NOT_FOUND
Debug.Print "File not found."
Case ERROR_PATH_NOT_FOUND
Debug.Print "Path not found."
Case ERROR_BAD_FORMAT
Debug.Print "The associated application is not a valid Win32 executable."
Case Else
Debug.Print "Associated application: " & Left$(buffer, lstrlen(buffer))
End Select
End Sub