Mein Ziel: Ich möchte das den Pfad für die AcroRd32.exe ermitteln (Adobe Acrobat Reader) - unabhängig von der Version des Adobe Readers.
Kannst Du das Ziel mal bitte näher erklären?

Ich hatte mal folgende Konstellation mit Adobe Acrobat:
Einige User haben diverse Versionen auf deren Kiste installiert. Da lungert Reader 4.0, Reader 5.0, Reader 6.0 und vielleicht auch noch die Vollversion x.0 rum.
Im Endeffekt ging es mir darum, den Pfad zu bekommen, den Windows verwendet, wenn User eine Adobe Acrobat - Datei vom Explorer aus startet.
Lösung - kannst das mal in einem Buhtong testen:
a) Ab in die Declarations:
Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (Byval lpFile As String, Byval lpDirectory As String, Byval sResult As String) As Long
b) Für die Buhtong-Sub
| Sub Click(Source As Button) |
| |
| Dim success As Long |
| Dim pos As Long |
| Dim sResult As String |
| Dim szEndergebnis As String |
| |
| '********** Filerequester |
| Dim workspace As New NotesUIWorkspace |
| Dim vFiles As Variant |
| vFiles = workspace.OpenFileDialog(False, "Bitte Datei auswählen.....", "", "c:\") |
| If Isempty(vFiles) Then Exit Sub ' Script verlassen falls User keine Datei auswählt |
| |
| Dim szFilepfadName As String |
| szFilepfadName = vFiles(0) |
| |
| '*********** File auswerten |
| 'Filename |
| Dim szFilename As String |
| szFilename = Rightback (szFilepfadName, "\") |
| 'Filepfad holen |
| Dim iName As Integer |
| Dim iGesamt As Integer |
| Dim iPfad As Integer |
| iName = Len(szFilename) |
| iGesamt = Len(szFilepfadName) |
| iPfad = iGesamt - iName |
| |
| Dim szFilepfad As String |
| szFilepfad = Left$(szFilepfadName, iPfad) |
| |
| 'Start Errorhandling |
| Dim ERROR_FILE_NO_ASSOCIATION As Long |
| Dim ERROR_FILE_NOT_FOUND As Long |
| Dim ERROR_PATH_NOT_FOUND As Long |
| Dim ERROR_FILE_SUCCESS As Long |
| Dim ERROR_BAD_FORMAT As Long |
| ERROR_FILE_NO_ASSOCIATION = 31 |
| ERROR_FILE_NOT_FOUND = 2 |
| ERROR_PATH_NOT_FOUND = 3 |
| ERROR_FILE_SUCCESS = 32 |
| ERROR_BAD_FORMAT = 11 |
| 'Ende Errorhandling |
| |
| Dim MAX_PATH As Long |
| MAX_PATH = 260 |
| sResult = Space$(MAX_PATH) |
| |
| success = FindExecutable(szFilename, szFilepfad, sResult) |
| |
| Select Case success |
| Case ERROR_FILE_NO_ASSOCIATION: msg = "no association" |
| Case ERROR_FILE_NOT_FOUND: msg = "file not found" |
| Case ERROR_PATH_NOT_FOUND: msg = "path not found" |
| Case ERROR_BAD_FORMAT: msg = "bad format" |
| |
| Case Is >= ERROR_FILE_SUCCESS: |
| pos = Instr(sResult, Chr$(0)) |
| |
| If pos Then |
| szEndergebnis = Left$(sResult, pos - 1) |
| End If |
| |
| End Select |
| |
| Msgbox "Hier das Testergebnis:" & Chr(10) & Chr(10) & szEndergebnis, 64, "Ergebnis" |
| |
| End Sub |
c) Noch eine RightBack - Function die der Code verwendet, also kopier das noch rein:
| Function RightBack (sourceString As String, searchString As String) As String |
| |
| For i% = Len(sourceString) To 1 Step -1 |
| sourceStringBack$=sourceStringBack$ & Mid(sourceString, i%, 1) |
| Next |
| |
| For i% = Len(searchString) To 1 Step -1 |
| searchStringBack$=searchStringBack$ & Mid(searchString, i%, 1) |
| Next |
| |
| pos% = Instr ( sourceStringBack$, searchStringBack$) |
| |
| If pos% > 0 Then pos% = pos% - 1 |
| result$ = Left ( sourceStringBack$, pos%) |
| |
| For i% = Len(result$) To 1 Step -1 |
| turn$=turn$ & Mid(result$, i%, 1) |
| Next |
| |
| RightBack=turn$ |
| |
| End Function |
Damit wird Dir in der Msgbox der komplette Pfad+Dateiname angezeigt, mit dem die ausgewählte Anwendung ausgeführt wird von Windows.