1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
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
|