Das VB Pendant von Konstantin Gross´ C# Function zur Ermittlung der Ausführbaren Dateien anhan der Erweiterung.
Imports System.IO
Imports System.Management
Imports System.Text
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System.Drawing
Declare Function FindExecutableA Lib "shell32.dll" ( _
ByVal lpFile As String, _
ByVal lpDirectory As String, _
ByVal lpResult As String) As Long
Declare Function GetTempPath Lib "kernel32.dll" _
Alias "GetTempPathA" ( _
ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long
Const cMAX_PATH = 260
Public Shared Function GetPathFileExtention(ByVal extension As String) As String
Try
Dim tempFileName As String = Path.ChangeExtension(Path.GetTempFileName(), extension)
Dim tempPathFile As String = Path.Combine("temp", tempFileName)
File.Create(tempFileName)
Dim lpResult As String
Dim lngRet As Long
lpResult = Space(cMAX_PATH)
lngRet = FindExecutableA(tempFileName.ToString, tempPathFile.ToString, lpResult)
If lngRet > 32 Then
GetPathFileExtention = lpResult
Return lpResult.ToString()
Else
Return "No Application found"
End If
Catch ex As Exception
Return "No Application found"
End Try
End Function
Kommentare zum Snippet