Gruppe
API
Problem
Die mit einer Datei-Suffix verknüpfte Anwendung wird incl. Pfad ausgelesen.
StandardModule: Modul1
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 Konstanen
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
Sub GetApplication()
Dim Retval As Long, Puffer As String
Puffer = Space(256)
Retval = FindExecutable(Range("A1").Value, "", Puffer)
Select Case Retval
Case 0
MsgBox "Es ist nicht genügend Speicher vorhanden, " & _
"um diese Funktion durchzuführen."
Case 31
MsgBox "Für diese Datei existiert keine verknüpfte Anwendung!"
Case ERROR_FILE_NOT_FOUND
MsgBox "Die angegebene Datei wurde nicht gefunden."
Case ERROR_PATH_NOT_FOUND
MsgBox "Der angegebene Pfad wurde nicht gefunden"
Case ERROR_BAD_FORMAT
MsgBox "Die verknüpfte Anwendung ist ungültig oder keine Win32 Anwendung"
Case Else
MsgBox "Verknüpfte Anwendung: " & left$(Puffer, lstrlen(Puffer))
End Select
End Sub